[issue25664] Unexpected UnicodeDecodeError in logging module

2015-11-24 Thread STINNER Victor

STINNER Victor added the comment:

$ cat x.py 
# coding=utf-8
import logging
logging.basicConfig(format='%(name)s %(message)s')
logger = logging.getLogger(u'测试')
logger.error(u'测试')

$ python2.7 x.py 
Traceback (most recent call last):
  File "/usr/lib64/python2.7/logging/__init__.py", line 859, in emit
msg = self.format(record)
  File "/usr/lib64/python2.7/logging/__init__.py", line 732, in format
return fmt.format(record)
  File "/usr/lib64/python2.7/logging/__init__.py", line 474, in format
s = self._fmt % record.__dict__
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 0: ordinal 
not in range(128)
Logged from file x.py, line 8

--
nosy: +haypo

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25664] Unexpected UnicodeDecodeError in logging module

2015-11-24 Thread Zephor Wu

Zephor Wu added the comment:

here is the case, sorry again for just typing it before and not testing it 
myself :)


# coding=utf-8
import logging

logging.basicConfig(format='%(name)s %(message)s')

logger = logging.getLogger(u'测试')
logger.error(u'测试')


btw, i'm using python2.7.10, mac osx 10.11, but i think this can effect all 
python2

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25664] Unexpected UnicodeDecodeError in logging module

2015-11-24 Thread Zephor Wu

Zephor Wu added the comment:

sorry, i forgot this:

logging.basicConfig(format='%(name)s %(message)s')

the error raised at the processing of the format while the name is 'utf-8' 
encoded and the message is an unicode

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25664] Unexpected UnicodeDecodeError in logging module

2015-11-24 Thread Vinay Sajip

Vinay Sajip added the comment:

I cannot reproduce, see below. Which exact version of Python are you using, and 
on what platform, and with what locale?

$ more logtest9.py
# coding=utf-8
import logging

logger = logging.getLogger(u'测试')
logger.error(u'测试')
$ python2.7 logtest9.py 
No handlers could be found for logger "测试"

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25664] Unexpected UnicodeDecodeError in logging module

2015-11-19 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +vinay.sajip

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25664] Unexpected UnicodeDecodeError in logging module

2015-11-18 Thread Zephor Wu

Changes by Zephor Wu :


--
type:  -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25664] Unexpected UnicodeDecodeError in logging module

2015-11-18 Thread Zephor Wu

New submission from Zephor Wu:

# coding=utf-8
import logging

logger = logging.getLogger(u'测试')
logger.error(u'测试')

# these code will get an unexpected error
# because getLogger encode the unicode to utf-8 while _log don't
# see line 474 in logging/__init__.py
# my suggestion is to keep the encoding in logging same with python2 with 
unicode

--
components: Library (Lib)
messages: 254881
nosy: zephor
priority: normal
severity: normal
status: open
title: Unexpected UnicodeDecodeError in logging module
versions: Python 2.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com