logging module and binary strings

F

Frank Aune

Hello,

---- snip ----Traceback (most recent call last):
File "/usr/lib/python2.6/logging/__init__.py", line 773, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xfe in position 10:
ordinal not in range(128)Traceback (most recent call last):
File "/usr/lib/python2.6/logging/__init__.py", line 773, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'utf8' codec can't decode byte 0xfe in position 10:
unexpected code byte

---- snip ----

Is there any way to log the above value of x "properly" using the python
logging module? By properly I mean logging the value displayed when entering
just x in the python shell and pressing enter.

Regards,
Frank
 
P

Peter Otten

Frank said:
Traceback (most recent call last):
File "/usr/lib/python2.6/logging/__init__.py", line 773, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xfe in position 10:
ordinal not in range(128)
Traceback (most recent call last):
File "/usr/lib/python2.6/logging/__init__.py", line 773, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'utf8' codec can't decode byte 0xfe in position 10:
unexpected code byte
Is there any way to log the above value of x "properly" using the python
logging module? By properly I mean logging the value displayed when
entering just x in the python shell and pressing enter.

How about logging.info(repr(x))?

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,060
Latest member
BuyKetozenseACV

Latest Threads

Top