UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte
Dave Angel
davea at davea.name
Fri Jul 5 04:27:23 EDT 2013
On 07/05/2013 03:13 AM, Νίκος Gr33k wrote:
> Στις 5/7/2013 10:06 πμ, ο/η Lele Gaifax έγραψε:
>> try:
>> host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0]
>> except:
>> host = "Reverse DNS Failed"
>
>
> Yes i uses to had it like that, until i was looking for ways to make it
> hold the error
>
> except Exception as e:
> print( e )
> host = e
>
> but print( e ) in the way i used to had it doesn't print out the error,
> it instead gives an internal server error on browser.
>
> I must somehow take a look at the error to understand why every visitor
> i have gets UnResolved, but how since prints fails?
>
How have you been doing it all along? Just open a console onto that
server, start the appropriate version of Python interactively, and try
the things we've been talking about. If it fails the same way as within
the cgi environmnet, you get full visibility.
Or if the problems cannot be recreated outside the cgi environment, use
the log files you've been logging other problems into. Or simply open a
text file for writing, and add a file= keyword parameter to the print
function call.
print(repr(e), file=myfile)
--
DaveA
More information about the Python-list
mailing list