[issue26227] Windows: socket.gethostbyaddr(name) fails for non-ASCII hostname
Eryk Sun
report at bugs.python.org
Thu Jan 28 02:55:38 EST 2016
Eryk Sun added the comment:
The patch is missing the "errors" parameter of PyUnicode_DecodeLocale. But it should call PyUnicode_DecodeMBCS instead. In the "C" locale, PyUnicode_DecodeLocale is Latin-1 because the CRT mbstowcs just casts the values to wchar_t.
socket_getnameinfo also decodes as UTF-8:
>>> socket.getnameinfo(('127.0.0.1', 20), 0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 0: invalid start byte
Steve, does your suggestion include reimplementing socket.gethostbyaddr and socket.gethostbyname_ex using GetNameInfoW and GetAddrInfoW? gethostbyaddr and gethostbyname are deprecated and lack a Unicode implementation.
----------
nosy: +eryksun
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26227>
_______________________________________
More information about the Python-bugs-list
mailing list