UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

Lele Gaifax lele at metapensiero.it
Thu Jul 4 22:44:10 CEST 2013


Ferrous Cranus <nikos at superhost.gr> writes:

> try:
> 	host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0]
> except:
> 	host = "Reverse DNS Failed"
>
> Is there a way to write the above so i cna print the error return when
> it fails?

Try something like

try:
	host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0]
except Exception as e:
	host = "Reverse DNS Failed"
        print(e)

?

ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele at metapensiero.it  |                 -- Fortunato Depero, 1929.




More information about the Python-list mailing list