There was an error while loading. Please reload this page.
1 parent cdad272 commit dc516efCopy full SHA for dc516ef
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
@@ -5508,7 +5508,7 @@ sock_decode_hostname(const char *name)
5508
#ifdef MS_WINDOWS
5509
/* Issue #26227: gethostbyaddr() returns a string encoded
5510
* to the ANSI code page */
5511
- return PyUnicode_DecodeFSDefault(name);
+ return PyUnicode_DecodeMBCS(name, strlen(name), "surrogatepass");
5512
#else
5513
/* Decode from UTF-8 */
5514
return PyUnicode_FromString(name);
0 commit comments