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 lemburg
Recipients lemburg, loewis, ned.deily
Date 2010-10-14.18:22:36
SpamBayes Score 1.7450058e-10
Marked as misclassified No
Message-id <4CB74A6A.3040508@egenix.com>
In-reply-to <4CB73AB2.1010901@v.loewis.de>
Content
Martin v. Löwis wrote:
> 
> Martin v. Löwis <martin@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()).

If think you are misunderstanding. The DNS name of a machine *is*
it's node name.

From the gethostname man page:

   Glibc Notes
       The  GNU  C library implements gethostname() as a library function that calls
       uname(2) and copies up to len bytes from the  returned  nodename  field  into
       name.

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

The MS API returns the DNS name as Unicode, so you don't into
those encoding in the first place.

I'll close this report as won't fix, since it's not platform.uname()
that needs to be fixed, but socket.gethostname() and that's issue
9377.

I'll copy the URLs to that issue.
History
Date User Action Args
2010-10-14 18:22:38lemburgsetrecipients: + lemburg, loewis, ned.deily
2010-10-14 18:22:37lemburglinkissue10097 messages
2010-10-14 18:22:36lemburgcreate