This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author loewis
Recipients baikie, ezio.melotti, jesterKing, lemburg, loewis, r.david.murray, vstinner
Date 2010-10-29.17:44:50
SpamBayes Score 1.1958941e-08
Marked as misclassified No
Message-id <>
I just did an experiment on Windows 7. I used SetComputerNameEx to set the NetBIOS name (4) to "e2718", and the DNS name (5) to "π3141"; then I rebooted. This is on a system with windows-1252 as its ANSI code page (i.e. u"π"==u"\N{GREEK SMALL LETTER PI}" is not in the ANSI charset.  After the reboot, I found

- COMPUTERNAME is "P3141", and so is the result of GetComputerNameEx(4)
- GetComputerNameEx(5) is "π3141"
- socket.gethostname of Python 2.5 returns "p3141".

So my theory of how this all fits together is this:

1. it's not really possible to completely decouple the DNS name and the NetBIOS name. Setting the DNS name also modifies the NetBIOS name; I suspect that the reverse is also true.

2. gethostname returns the ANSI version of the DNS name (which happens to convert the GREEK SMALL LETTER PI to a LATIN SMALL LETTER P).

3. the NetBIOS name is an generally an uppercase version of the gethostname result. There may be rules in case the gethostname result contains characters illegal in NetBIOS.

In summary, I (now) think it's fine to return the Unicode version of the DNS name from gethostname on Windows.

Re msg119271: the name "π3141" really has nothing to do with the DNS on my system. It doesn't occur in DNS any zone, nor could it possibly. It's unclear to me why Microsoft calls it the "DNS name".
Date User Action Args
2010-10-29 17:44:52loewissetrecipients: + loewis, lemburg, vstinner, baikie, ezio.melotti, r.david.murray, jesterKing
2010-10-29 17:44:52loewissetmessageid: <>
2010-10-29 17:44:51loewislinkissue9377 messages
2010-10-29 17:44:50loewiscreate