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 baikie, ezio.melotti, jesterKing, lemburg, loewis, r.david.murray, vstinner
Date 2010-10-29.18:33:14
SpamBayes Score 4.440892e-16
Marked as misclassified No
Message-id <>
In-reply-to <>
Martin v. Löwis wrote:
> Martin v. Löwis <> 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.

The MS docs mention that setting the DNS name will adjust the NetBIO name
as well (with the NetBIOS name being converted to upper case and truncated,
if the DNS name is too long).

They don't mention anything about the NetBIOS name encoding.

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

The DNS name of the Windows machine is the combination of the DNS host
name and the DNS domain that you setup on the machine. I think the
misunderstanding is that you assume this combination will
somehow appear as known DNS name of the machine via some
DNS server on the network - that's not the case.

Of course, it's not particularly useful to set the DNS name to
something that other machines cannot find out via an DNS query.

FWIW, you can do the same on a Linux box, i.e. setup the host name
and domain to some completely bogus values. And as David pointed out,
without also updating the /etc/hosts on the Linux, you always get the
resolver error with hostname -f I mentioned earlier on (which does
a DNS lookup), so there's no real connection to the DNS system on
Linux either.
Date User Action Args
2010-10-29 18:33:17lemburgsetrecipients: + lemburg, loewis, vstinner, baikie, ezio.melotti, r.david.murray, jesterKing
2010-10-29 18:33:15lemburglinkissue9377 messages
2010-10-29 18:33:14lemburgcreate