Hello although my code is correct just today i saw this in the error_log

[Sun Sep 29 07:44:43 2013] [error] [client 173.245.49.126] Traceback (most recent call last): [Sun Sep 29 07:44:43 2013] [error] [client 173.245.49.126] File "/home/nikos/public_html/cgi-bin/metrites.py", line 30, in <module> [Sun Sep 29 07:44:43 2013] [error] [client 173.245.49.126] host = socket.gethostbyaddr( ipval ) [0] [Sun Sep 29 07:44:43 2013] [error] [client 173.245.49.126] UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte [Sun Sep 29 07:44:43 2013] [error] [client 173.245.49.126] Premature end of script headers: metrites.py


Which should never had happened since i use the following code:


ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or os.environ.get('REMOTE_ADDR', "Cannot Resolve") )
city = "Άγνωστη Πόλη"
host = "Άγνωστη Προέλευση"
try:
        gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat')
        city = gi.time_zone_by_addr( ipval )
        host = socket.gethostbyaddr( ipval ) [0]
except socket.gaierror as e:
print( "metrites.py => (%s): " % lastvisit, repr( sys.exc_info() ), file=open('/tmp/err.out', 'w') )

So vene if somethign might have gone wrong with the 'host' assignment, 'host' should have defaulted to "Άγνωστη Προέλευση"

why the utf-8 error?
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to