[issue19267] Logging to file does not accept UTF16

2013-10-15 Thread Paweł Wroniszewski
New submission from Paweł Wroniszewski: The following code reproduces the error: import logging logging.root.addHandler(logging.FileHandler(filename='test.log',encoding='UTF16')) logging.error( u'b\u0142\u0105d') I think the problem is in the line logging/__init__.py:860: ufs =

[issue19267] Logging to file does not accept UTF16

2013-10-15 Thread STINNER Victor
STINNER Victor added the comment: The example works fine on Python3: localhost$ python3 Python 3.3.2 (default, Aug 23 2013, 19:00:04) [GCC 4.8.1 20130603 (Red Hat 4.8.1-1)] on linux Type help, copyright, credits or license for more information. import logging

[issue19267] Logging to file does not accept UTF16

2013-10-15 Thread STINNER Victor
STINNER Victor added the comment: I don't understand the purpose of fs.decode(stream.encoding): why not directly using ufs=u'%s\n? @Pawel: Can you please try to replace ufs=fs.decode(stream.encoding) with ufs=u'%s\n'? -- ___ Python tracker

[issue19267] Logging to file does not accept UTF16

2013-10-15 Thread Paweł Wroniszewski
Paweł Wroniszewski added the comment: Hi Victor. Your fix works, but actually using simply ufs='%s\n' also seem to work, as type( '%s' % u'foo') and type( u'%s' % u'foo') returns the same - unicode. So I would suggest dropping ufs completely, and changing the two occurences to fs. It works

[issue19267] Logging to file does not accept UTF16

2013-10-15 Thread Paweł Wroniszewski
Paweł Wroniszewski added the comment: Btw I also don't see the purspose of fs.decode(stream.encoding), as it should rather be encoded and not decoded... -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19267

[issue19267] Logging to file does not accept UTF16

2013-10-15 Thread Natal Ngétal
Natal Ngétal added the comment: Hi, here the patch to fix this bug on Python 2.7 with a test suite. -- nosy: +hobbestigrou Added file: http://bugs.python.org/file32137/patch_utf16 ___ Python tracker rep...@bugs.python.org

[issue19267] Logging to file does not accept UTF16

2013-10-15 Thread STINNER Victor
STINNER Victor added the comment: patch_utf16 looks good to me. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19267 ___ ___ Python-bugs-list

[issue19267] Logging to file does not accept UTF16

2013-10-15 Thread STINNER Victor
Changes by STINNER Victor victor.stin...@gmail.com: -- components: +Unicode nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19267 ___

[issue19267] Logging to file does not accept UTF16

2013-10-15 Thread Roundup Robot
Roundup Robot added the comment: New changeset e94e29dab32c by Victor Stinner in branch '2.7': Close #19267: Fix support of multibyte encoding (ex: UTF-16) in the logging http://hg.python.org/cpython/rev/e94e29dab32c -- nosy: +python-dev resolution: - fixed stage: - committed/rejected

[issue19267] Logging to file does not accept UTF16

2013-10-15 Thread STINNER Victor
STINNER Victor added the comment: This bug is specific to Python 2. I should now be fixed, thanks Paweł for the report and Natal for the patch. @Natal: Could you please sign the Contributor Agreement for next contributions? http://www.python.org/psf/contrib/contrib-form/ --

[issue19267] Logging to file does not accept UTF16

2013-10-15 Thread Paweł Wroniszewski
Paweł Wroniszewski added the comment: Cool - looks good to me as well. Thanks guys. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19267 ___ ___

[issue19267] Logging to file does not accept UTF16

2013-10-15 Thread Jesús Cea Avión
Changes by Jesús Cea Avión j...@jcea.es: -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19267 ___ ___ Python-bugs-list mailing list