> 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 _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com