]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-26227: Fixes decoding of host names on Windows from ANSI instead of UTF-8 (GH...
authorSteve Dower <steve.dower@python.org>
Wed, 21 Apr 2021 23:18:20 +0000 (00:18 +0100)
committerGitHub <noreply@github.com>
Wed, 21 Apr 2021 23:18:20 +0000 (00:18 +0100)
Misc/NEWS.d/next/Windows/2021-04-21-23-37-34.bpo-26227.QMY_eA.rst [new file with mode: 0644]
Modules/socketmodule.c

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 (file)
index 0000000..d6826fb
--- /dev/null
@@ -0,0 +1,2 @@
+Fixed decoding of host names in :func:`socket.gethostbyaddr` and
+:func:`socket.gethostbyname_ex`.
index 23aab59d9749adc17ea5e71c332700da5d75d8db..79559c04d5104da9a1a94da0b6b6c2afe47b9134 100644 (file)
@@ -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);