Skip to content

Commit dc516ef

Browse files
authored
bpo-26227: Fixes decoding of host names on Windows from ANSI instead of UTF-8 (pythonGH-25510)
1 parent cdad272 commit dc516ef

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fixed decoding of host names in :func:`socket.gethostbyaddr` and
2+
:func:`socket.gethostbyname_ex`.

Modules/socketmodule.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -5508,7 +5508,7 @@ sock_decode_hostname(const char *name)
55085508
#ifdef MS_WINDOWS
55095509
/* Issue #26227: gethostbyaddr() returns a string encoded
55105510
* to the ANSI code page */
5511-
return PyUnicode_DecodeFSDefault(name);
5511+
return PyUnicode_DecodeMBCS(name, strlen(name), "surrogatepass");
55125512
#else
55135513
/* Decode from UTF-8 */
55145514
return PyUnicode_FromString(name);

0 commit comments

Comments
 (0)