Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'mrab': 0.05; "subject:' ": 0.07; 'subject:position': 0.09; 'try:': 0.09; 'cc:addr:python- list': 0.11; 'ensured': 0.16; 'oserror': 0.16; 'subject: \n ': 0.16; 'subject:start': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'module': 0.19; 'thu,': 0.19; 'cc:addr:python.org': 0.22; 'header :User-Agent:1': 0.23; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'logging': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'host': 0.29; "skip:' 10": 0.31; 'produces': 0.31; 'actual': 0.34; 'except': 0.35; 'error.': 0.37; 'skip:o 20': 0.38; 'server': 0.38; 'subject:can': 0.39; 'sure': 0.39; 'how': 0.40; 'catch': 0.60; 'is.': 0.60; "you've": 0.63; '8bit%:92': 0.71; 'jul': 0.74; '2013,': 0.91 Date: Fri, 12 Jul 2013 06:47:53 -0500 (CDT) From: Wayne Werner X-X-Sender: wayne@gilgamesh To: =?ISO-8859-7?B?zd/q7/Igw+rxMzPq?= Subject: Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte In-Reply-To: References: <51D57ADB.3050202@superhost.gr> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323329-1415386919-1373629673=:2674" Cc: python-list@python.org 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: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1373629687 news.xs4all.nl 16009 [2001:888:2000:d::a6]:43222 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:50519 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1415386919-1373629673=:2674 Content-Type: TEXT/PLAIN; charset=utf-8; format=flowed Content-Transfer-Encoding: 8BIT On Thu, 4 Jul 2013, Νίκος Γκρ33κ wrote: > Στις 4/7/2013 6:10 μμ, ο/η MRAB έγραψε: >> What do you mean "I don't know how to catch the exception with >> OSError"? You've tried "except socket.gaierror" and "except >> socket.herror", well just write "except OSError" instead! > > > try: > host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] > except OSError: > host = "UnResolved" > > produces also an internal server error. > > Are you sure is just except OSError ? > Have you ensured that 'REMOTE_ADDR' is actually a key in os.environ? I highly recommend using the logging module to help diagnose what the actual exception is. HTH, -W --8323329-1415386919-1373629673=:2674--