UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
benjamin.kaplan at case.edu
Fri Jul 5 09:21:06 CEST 2013
On Jul 5, 2013 12:12 AM, "Lele Gaifax" <lele at metapensiero.it> wrote:
> Νίκος Gr33k <nikos at superhost.gr> writes:
> > try:
> > host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )
> > except Exception as e:
> > host = "Reverse DNS Failed"
> > How can the above code not be able to reeverse dns any more and it
> > falls back to the failed string?
> The only way to know is actually printing out the exception, either to
> stderr, or better using the logging facility, as I suggested.
> FYI, your code above is (almost) exactly equivalent to the simpler
> host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )
> host = "Reverse DNS Failed"
> ciao, lele.
They aren't equivalent. "except Exception" won't catch KeyboardInterrupt or
SystemExit or a few others that you really don't want to catch in a generic
error handler. You should almost never have a bare except.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list