UnicodeDecodeError issue
Ferrous Cranus
nikos at superhost.gr
Sat Aug 31 03:58:43 EDT 2013
Στις 31/8/2013 10:25 πμ, ο/η Peter Otten έγραψε:
> Ferrous Cranus wrote:
>
>> Suddenly my webiste superhost.gr running my main python script presents
>> me with this error:
>
>> Code:
>> UnicodeDecodeError('utf-8', b'\xb6\xe3\xed\xf9\xf3\xf4\xef
>> \xfc\xed\xef\xec\xe1 \xf3\xf5\xf3\xf4\xde\xec\xe1\xf4\xef\xf2', 0, 1,
>> 'invalid start byte')
>
>> Does anyone know what this means?
>
>>>> b'\xb6\xe3\xed\xf9\xf3\xf4\xef\xfc\xed\xef\xec\xe1\xf3\xf5\xf3\xf4\xde\xec\xe1\xf4\xef\xf2'.decode("iso-8859-7")
> 'Unknown hostname'
>
>
Thanks you decoded in greek-iso, coll thinking!
But llok:
Why can the host varibale be unset since iam using this:
try:
gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat')
city = gi.time_zone_by_addr( os.environ['REMOTE_ADDR'] ) or
gi.time_zone_by_addr( os.environ['HTTP_CF_CONNECTING_IP'] )
host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] ) or
socket.gethostbyaddr( os.environ['HTTP_CF_CONNECTING_IP'] ) or 'Αγνωστη
Προέλευση'
except Exception as e:
err = repr(e)
==================
it gets set to string 'Αγνωστη Προέλευση' if in case visitor's remote ip
address cannot be resolved.
So that error should arise at all.
--
Webhost <http://superhost.gr>
More information about the Python-list
mailing list