UnicodeDecodeError issue
Ferrous Cranus
nikos at superhost.gr
Sat Aug 31 04:31:13 EDT 2013
Here is the code inside files.py:
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
os.environ['REMOTE_ADDR']
except Exception as e:
print( repr(e), file=open( '/tmp/err.out', 'w' ) )
that produces this:
[Sat Aug 31 08:29:33 2013] [error] [client 108.162.229.116] ValueError:
underlying buffer has been detached, referer: http://superhost.gr/
[Sat Aug 31 08:29:33 2013] [error] [client 108.162.229.116] , referer:
http://superhost.gr/
[Sat Aug 31 08:29:33 2013] [error] [client 108.162.229.116] Original
exception was:, referer: http://superhost.gr/
[Sat Aug 31 08:29:33 2013] [error] [client 108.162.229.116] Traceback
(most recent call last):, referer: http://superhost.gr/
[Sat Aug 31 08:29:33 2013] [error] [client 108.162.229.116] File
"/home/nikos/public_html/cgi-bin/files.py", line 135, in <module>,
referer: http://superhost.gr/
[Sat Aug 31 08:29:33 2013] [error] [client 108.162.229.116]
cur.execute('''INSERT INTO files (url, host, city, lastvisit) VALUES
(%s, %s, %s, %s)''', (filename, host, city, lastvisit) ), referer:
http://superhost.gr/
[Sat Aug 31 08:29:33 2013] [error] [client 108.162.229.116] NameError:
name 'host' is not defined, referer: http://superhost.gr/
But 'host' defaults to an ip address if it cannot resolve the hostname.
Why the errro says its undefined?
More information about the Python-list
mailing list