Martin v. Löwis <mar...@v.loewis.de> added the comment:

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".

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9377>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to