Skip to content

Commit f7bc441

Browse files
bpo-26227: Fixes decoding of host names on Windows from ANSI instead of UTF-8 (GH-25510)
(cherry picked from commit dc516ef) Co-authored-by: Steve Dower <steve.dower@python.org>
1 parent 602eefe commit f7bc441

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
@@ -5474,7 +5474,7 @@ sock_decode_hostname(const char *name)
54745474
#ifdef MS_WINDOWS
54755475
/* Issue #26227: gethostbyaddr() returns a string encoded
54765476
* to the ANSI code page */
5477-
return PyUnicode_DecodeFSDefault(name);
5477+
return PyUnicode_DecodeMBCS(name, strlen(name), "surrogatepass");
54785478
#else
54795479
/* Decode from UTF-8 */
54805480
return PyUnicode_FromString(name);

0 commit comments

Comments
 (0)