UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

Nobody nobody at nowhere.com
Fri Jul 5 02:06:42 CEST 2013

On Thu, 04 Jul 2013 13:38:09 +0300, Νίκος wrote:

> So you are also suggesting that what gesthostbyaddr() returns is not 
> utf-8 encoded too?

The gethostbyaddr() OS function returns a byte string with no specified
encoding. Python 3 will doubtless try to decode that to a character string
using some (probably unspecified) encoding.

Names obtained from DNS should consist entirely of ASCII characters
(gethostbyname shouldn't attempt to decode internationalised names
which use IDN, it should return the raw data).

Names obtained by other means (e.g. /etc/hosts or Active Directory) could
contain anything, but if you use non-ASCII hostnames you're asking for

More information about the Python-list mailing list