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',
Vinay Sajip vinay_sa...@yahoo.co.uk added the comment:
i think it's all about the difference betwin print(msg) and
sys.stdout.write('%s\n' % msg)
Yes. Actually, it's about what streams will accept. For example, a
stream opened with codecs.open(encoding='cp1251') will accept a Unicode
string
Vinay Sajip vinay_sa...@yahoo.co.uk added the comment:
Fix checked into trunk and release26-maint.
--
resolution: accepted - fixed
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5170
Vinay Sajip vinay_sa...@yahoo.co.uk 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:
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
Vinay Sajip vinay_sa...@yahoo.co.uk 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,
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) or
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'Привет')#
Vinay Sajip vinay_sa...@yahoo.co.uk added the comment:
Sorry, misread the original issue and tested with Python 2.5 rather than
2.6. This is a regression; fix and additional test case checked into
trunk and release26-maint.
--
resolution: works for me - fixed
status: pending - closed
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)# it
Changes by Benjamin Peterson benja...@python.org:
--
assignee: - vsajip
nosy: +vsajip
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5170
___
___
Vinay Sajip vinay_sa...@yahoo.co.uk added the comment:
The attached test script and output file appear to show logging working
correctly. The script writes a log message including the Cyrillic text
доброе утро (Good morning) to a CP1251-encoded file, test.log. Opening
this file in a
12 matches
Mail list logo