diff -r cf70f030a744 Lib/logging/__init__.py --- a/Lib/logging/__init__.py Wed Jun 18 23:07:46 2014 -0400 +++ b/Lib/logging/__init__.py Mon Jun 23 22:07:14 2014 +0300 @@ -59,6 +59,7 @@ except NameError: _unicode = False + # # _srcfile is used when walking the stack to check when we've got the first # caller stack frame. @@ -1029,7 +1030,7 @@ rv = None if not isinstance(name, basestring): raise TypeError('A logger name must be string or Unicode') - if isinstance(name, unicode): + if _unicode and isinstance(name, unicode): name = name.encode('utf-8') _acquireLock() try: diff -r cf70f030a744 Lib/test/test_logging.py --- a/Lib/test/test_logging.py Wed Jun 18 23:07:46 2014 -0400 +++ b/Lib/test/test_logging.py Mon Jun 23 22:07:14 2014 +0300 @@ -37,7 +37,8 @@ import struct import sys import tempfile -from test.test_support import captured_stdout, run_with_locale, run_unittest +from test.test_support import captured_stdout, run_with_locale, run_unittest, \ + have_unicode, requires_unicode, u import textwrap import time import unittest @@ -73,7 +74,8 @@ # This is to test correct operation when sorting existing # loggers in the configuration code. See issue 8201. logging.getLogger("\xab\xd7\xbb") - logging.getLogger(u"\u013f\u00d6\u0047") + if have_unicode: + logging.getLogger(u(r"\u013f\u00d6\u0047")) self.root_logger = logging.getLogger("") self.original_logging_level = self.root_logger.getEffectiveLevel() @@ -1037,10 +1039,11 @@ if os.path.isfile(fn): os.remove(fn) + @requires_unicode def test_encoding_cyrillic_unicode(self): log = logging.getLogger("test") #Get a message in Unicode: Do svidanya in Cyrillic (meaning goodbye) - message = u'\u0434\u043e \u0441\u0432\u0438\u0434\u0430\u043d\u0438\u044f' + message = u(r'\u0434\u043e \u0441\u0432\u0438\u0434\u0430\u043d\u0438\u044f') #Ensure it's written in a Cyrillic encoding writer_class = codecs.getwriter('cp1251') writer_class.encoding = 'cp1251' @@ -1058,10 +1061,11 @@ #Compare against what the data should be when encoded in CP-1251 self.assertEqual(s, '\xe4\xee \xf1\xe2\xe8\xe4\xe0\xed\xe8\xff\n') + @requires_unicode def test_encoding_utf16_unicode(self): # Issue #19267 log = logging.getLogger("test") - message = u'b\u0142\u0105d' + message = u(r'b\u0142\u0105d') writer_class = codecs.getwriter('utf-16-le') writer_class.encoding = 'utf-16-le' stream = cStringIO.StringIO() @@ -1882,6 +1886,7 @@ logging.config.stopListening() t.join(2.0) + @requires_unicode # XXX json needs unicode support def test_listen_config_10_ok(self): with captured_stdout() as output: self.setup_via_listener(json.dumps(self.config10))

AltStyle によって変換されたページ (->オリジナル) /