[issue5170] logging to file + encoding
shamilbi
report at bugs.python.org
Sun Feb 8 14:36:23 CET 2009
shamilbi <shamilbi at gmail.com> added the comment:
test_log.py:
-----------
#! -*- coding: windows-1251 -*-
import logging
logger = logging.getLogger('test_log')
logger.addHandler(logging.FileHandler('test.log', encoding='cp1251'))
logger.setLevel(logging.DEBUG)
logger.debug(u'Привет') # russian Hello
exception:
---------
Traceback (most recent call last):
File "e:\bin\python\0\lib\logging\__init__.py", line 765, in emit
self.stream.write(fs % msg.encode("UTF-8"))
File "e:\bin\python\0\lib\codecs.py", line 686, in write
return self.writer.write(data)
File "e:\bin\python\0\lib\codecs.py", line 351, in write
data, consumed = self.encode(object, self.errors)
File "e:\bin\python\0\lib\encodings\cp1251.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_table)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0:
ordinal not in range(128)
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5170>
_______________________________________
More information about the Python-bugs-list
mailing list