Skip to content

Commit 6dfbb8e

Browse files
zoobamiss-islington
authored andcommitted
bpo-26227: Fixes decoding of host names on Windows from ANSI instead of UTF-8 (pythonGH-25510)
(cherry picked from commit dc516ef) Co-authored-by: Steve Dower <steve.dower@python.org>
1 parent fa03efd commit 6dfbb8e

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

Lines changed: 2 additions & 0 deletions
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‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5557,7 +5557,7 @@ sock_decode_hostname(const char *name)
55575557
#ifdef MS_WINDOWS
55585558
/* Issue #26227: gethostbyaddr() returns a string encoded
55595559
* to the ANSI code page */
5560-
return PyUnicode_DecodeFSDefault(name);
5560+
return PyUnicode_DecodeMBCS(name, strlen(name), "surrogatepass");
55615561
#else
55625562
/* Decode from UTF-8 */
55635563
return PyUnicode_FromString(name);

0 commit comments

Comments
 (0)