New submission from shamilbi shami...@gmail.com:
different eol when writing to fp = codecs.open(.., 'w', 'cp866')
(windows, python-2.6.4)
def write(fp):
fp.write(\
a
)
# eol=0d0a (windows, python-2.6.4)
with open('0d0a.tmp', 'w') as fp:
write(fp)
# eol=0d0a (windows, python-2.6.4
shamilbi shami...@gmail.com added the comment:
Trunk and release26-maint were recently changed (r71657, r71658) to use
the following logic, which differs from the code snippet you posted.
if (isinstance(msg, unicode) and
getattr(stream, 'encoding
shamilbi shami...@gmail.com added the comment:
Can you retry with setting the encoding attribute of the file to
cp1251? That should work and that should be the appropriate method to
avoid the problem.
test_logging.py in the Python distribution has a test which exercises
Unicode
shamilbi shami...@gmail.com added the comment:
(python 2.6.2, WinXP)
logging to console stopped working. Here is a workaround:
logging/__init__.py:
class StreamHandler(Handler):
...
def emit(self, record):
...
if (isinstance(msg, unicode
shamilbi shami...@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'Привет
New submission from shamilbi shami...@gmail.com:
if i configure logging into a file with encoding = 'cp1251' and do
logger.debug(u'...') then i get crash with UnicodeError
i suggest reimplementing method FileHandler.emit():
...
if isinstance(msg, unicode):
stream.write(f % msg