diff options
-rw-r--r-- | Misc/NEWS.d/next/Windows/2021-04-21-23-37-34.bpo-26227.QMY_eA.rst | 2 | ||||
-rw-r--r-- | Modules/socketmodule.c | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/Misc/NEWS.d/next/Windows/2021-04-21-23-37-34.bpo-26227.QMY_eA.rst b/Misc/NEWS.d/next/Windows/2021-04-21-23-37-34.bpo-26227.QMY_eA.rst new file mode 100644 index 0000000..d6826fb --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2021-04-21-23-37-34.bpo-26227.QMY_eA.rst @@ -0,0 +1,2 @@ +Fixed decoding of host names in :func:`socket.gethostbyaddr` and +:func:`socket.gethostbyname_ex`. diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 23aab59..79559c0 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -5508,7 +5508,7 @@ sock_decode_hostname(const char *name) #ifdef MS_WINDOWS /* Issue #26227: gethostbyaddr() returns a string encoded * to the ANSI code page */ - return PyUnicode_DecodeFSDefault(name); + return PyUnicode_DecodeMBCS(name, strlen(name), "surrogatepass"); #else /* Decode from UTF-8 */ return PyUnicode_FromString(name); |