[issue10097] platform.uname gives UnicodeError for non-ASCII computer names on Windows

Martin v. Löwis report at bugs.python.org
Thu Oct 14 19:15:34 CEST 2010


Martin v. Löwis <martin at v.loewis.de> added the comment:

> More evidence that the NetBIOS name is used:
> 
> http://msdn.microsoft.com/en-us/library/aa368009(VS.85).aspx
> http://msdn.microsoft.com/en-us/library/ms724295(v=VS.85).aspx
> 
> One problem with this approach is that changes to the NetBIOS name
> are not seen by those APIs and variables, e.g. if the machine
> get's an update via DHCP. The other is that NetBIOS itself is
> being phased out in favor of DNS names - which socket.gethostname()
> returns, so we'd be replacing a new technology with an old one.

I think you misunderstand. It's not that this API returns the NetBIOS
name, but that NetBIOS really uses the same name that people understand
as their "computer name".

It's incorrect to use DNS names when implementing platform.uname():
on POSIX, uname() *also* does not return the DNS name. If you want
some API to return the DNS name of the computer, you need a different
function (e.g. socket.getfqdn()).

> BTW: Why doesn't socket.gethostname() use GetComputerNameEx()
> which does support Unicode ?

gethostname was specified by Berkeley Unix (4.2BSD specifically).
Microsoft can't just change the signature of the function.

If you are asking whether Python's socket.gethostname calls
gethostname: because this is the whole point of this function.
It would be very confusing if the function didn't call the
same-named platform API.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10097>
_______________________________________


More information about the Python-bugs-list mailing list