There was an error while loading. Please reload this page.
1 parent fa03efd commit d8576b1Copy full SHA for d8576b1
2 files changed
Misc/NEWS.d/next/Windows/2021-04-21-23-37-34.bpo-26227.QMY_eA.rst
@@ -0,0 +1,2 @@
1
+Fixed decoding of host names in :func:`socket.gethostbyaddr` and
2
+:func:`socket.gethostbyname_ex`.
Modules/socketmodule.c
@@ -5557,7 +5557,7 @@ sock_decode_hostname(const char *name)
5557
#ifdef MS_WINDOWS
5558
/* Issue #26227: gethostbyaddr() returns a string encoded
5559
* to the ANSI code page */
5560
- return PyUnicode_DecodeFSDefault(name);
+ return PyUnicode_DecodeMBCS(name, strlen(name), "surrogatepass");
5561
#else
5562
/* Decode from UTF-8 */
5563
return PyUnicode_FromString(name);
0 commit comments