> I think size should be in TCHARs, not in bytes. (MSDN says so) > And GetComputerName's signature differs from MSDN. (Maybe should > use GetComputerNameExW again?) You are right. So how about this patch? Index: Modules/socketmodule.c =================================================================== --- Modules/socketmodule.c (Revision 85983) +++ Modules/socketmodule.c (Arbeitskopie) @@ -3098,16 +3098,16 @@ version of the hostname, whereas we need a Unicode string. Otherwise, gethostname apparently also returns the DNS name. */ wchar_t buf[MAX_COMPUTERNAME_LENGTH]; - DWORD size = sizeof(buf); + DWORD size = sizeof(buf)/sizeof(wchar_t); if (!GetComputerNameExW(ComputerNamePhysicalDnsHostname, buf, &size)) { if (GetLastError() == ERROR_MORE_DATA) { /* MSDN says this may occur "because DNS allows longer names */ PyObject *result = PyUnicode_FromUnicode(NULL, size); if (!result) return NULL; - if (GetComputerName(ComputerNamePhysicalDnsHostname, - PyUnicode_AS_UNICODE(result), - size+1)) + if (GetComputerNameExW(ComputerNamePhysicalDnsHostname, + PyUnicode_AS_UNICODE(result), + size+1)) return result; Py_DECREF(result); } Regards, Martin
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4