Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'charset:iso-8859-7': 0.04; 'output': 0.05; 'skip:\\ 20': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'skip:\\ 40': 0.09; 'try:': 0.09; '"w")': 0.16; 'dave.': 0.16; 'formatted': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:issue': 0.16; 'truncates': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'skip:p 40': 0.19; 'code,': 0.22; 'example': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; "haven't": 0.24; 'header:X-Complaints-To:1': 0.27; 'tried': 0.27; 'host': 0.29; 'said,': 0.30; "i'm": 0.30; 'code': 0.31; 'skip:= 20': 0.31; 'file': 0.32; 'running': 0.33; 'skip:b 30': 0.33; 'could': 0.34; 'except': 0.35; 'skip:u 20': 0.35; 'but': 0.35; 'useful': 0.36; 'should': 0.36; 'skip:o 20': 0.38; 'thank': 0.38; 'to:addr:python-list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'dave': 0.60; 'skip:o 30': 0.61; 'first': 0.61; 'information': 0.63; 'more': 0.64; 'afraid': 0.65; 'city': 0.66; 'response.': 0.68; 'angel': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dave Angel Subject: Re: UnicodeDecodeError issue Date: Sun, 1 Sep 2013 15:40:10 +0000 (UTC) References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-7 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: 174.32.174.36 User-Agent: XPN/1.2.6 (Street Spirit ; Linux) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1378050305 news.xs4all.nl 15991 [2001:888:2000:d::a6]:59046 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:53418 On 1/9/2013 09:59, Ferrous Cranus wrote: > Στις 1/9/2013 1:35 μμ, ο/η Dave Angel έγραψε: >> This is my first crack at it (untested): >> >> errout = open("/tmp/err.out", "w") #opens and truncates the error >> output file >> 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'] )[0] or >> socket.gethostbyaddr( os.environ['HTTP_CF_CONNECTING_IP'] )[0] or >> "Proxy Detected" >> except Exception as e: >> print( "Xyzzy exception-", repr(sys.exc_info()), file=errout) >> errout.flush() >> >> >> Note that I haven't had to use exc_info() in my own code, so I'm sure it >> could be formatted prettier. But right now, you need to stop throwing >> away useful information. > > First of all thank you for your detailed information Dave. > I have tried all you said, the above example you provided me, but i'm > afraid even with your approach which should have given more error > specific information the output of the err file remains. > > > nikos@superhost.gr [~]# cat /tmp/err.out > 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') > > > See my other response. The above file did NOT result from running the code above. It is missing the "Xyzzy" label. -- Signature file not found