[Python-checkins] r81919 - in python: branches/release26-maint/Lib/logging/__init__.py branches/release26-maint/Misc/NEWS trunk/Lib/logging/__init__.py trunk/Misc/NEWS
vinay.sajip
python-checkins at python.org
Sat Jun 12 00:56:50 CEST 2010
Author: vinay.sajip
Date: Sat Jun 12 00:56:50 2010
New Revision: 81919
Log:
Issue #8924: logging: Improved error handling for Unicode in exception text.
Modified:
python/branches/release26-maint/Lib/logging/__init__.py
python/branches/release26-maint/Misc/NEWS
python/trunk/Lib/logging/__init__.py
python/trunk/Misc/NEWS
Modified: python/branches/release26-maint/Lib/logging/__init__.py
==============================================================================
--- python/branches/release26-maint/Lib/logging/__init__.py (original)
+++ python/branches/release26-maint/Lib/logging/__init__.py Sat Jun 12 00:56:50 2010
@@ -445,7 +445,13 @@
if record.exc_text:
if s[-1:] != "\n":
s = s + "\n"
- s = s + record.exc_text
+ try:
+ s = s + record.exc_text
+ except UnicodeError:
+ # Sometimes filenames have non-ASCII chars, which can lead
+ # to errors when s is Unicode and record.exc_text is str
+ # See issue 8924
+ s = s + record.exc_text.decode(sys.getfilesystemencoding())
return s
#
Modified: python/branches/release26-maint/Misc/NEWS
==============================================================================
--- python/branches/release26-maint/Misc/NEWS (original)
+++ python/branches/release26-maint/Misc/NEWS Sat Jun 12 00:56:50 2010
@@ -71,6 +71,8 @@
Library
-------
+- Issue #8924: logging: Improved error handling for Unicode in exception text.
+
- Fix codecs.escape_encode to return the correct consumed size.
- Issue #6470: Drop UNC prefix in FixTk.
Modified: python/trunk/Lib/logging/__init__.py
==============================================================================
--- python/trunk/Lib/logging/__init__.py (original)
+++ python/trunk/Lib/logging/__init__.py Sat Jun 12 00:56:50 2010
@@ -473,7 +473,13 @@
if record.exc_text:
if s[-1:] != "\n":
s = s + "\n"
- s = s + record.exc_text
+ try:
+ s = s + record.exc_text
+ except UnicodeError:
+ # Sometimes filenames have non-ASCII chars, which can lead
+ # to errors when s is Unicode and record.exc_text is str
+ # See issue 8924
+ s = s + record.exc_text.decode(sys.getfilesystemencoding())
return s
#
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Sat Jun 12 00:56:50 2010
@@ -21,6 +21,7 @@
Library
-------
+- Issue #8924: logging: Improved error handling for Unicode in exception text.
- Issue #8948: cleanup functions and class / module setups and teardowns are
now honored in unittest debug methods.
More information about the Python-checkins
mailing list