Mercurial > cpython-lru_cache-weakref
diff Lib/traceback.py @ 61232:bb51e4bbff8c legacy-trunk
Issue #8313: traceback.format_exception_only() encodes unicode message to
ASCII with backslashreplace error handler if str(value) failed
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Wed, 05 May 2010 12:40:49 +0000 |
| parents | d5bf08c861a6 |
| children | b36cb4602e21 |
line wrap: on
line diff
--- a/Lib/traceback.py Tue May 04 19:08:18 2010 +0000 +++ b/Lib/traceback.py Wed May 05 12:40:49 2010 +0000 @@ -211,8 +211,14 @@ def _some_str(value): try: return str(value) - except: - return '<unprintable %s object>' % type(value).__name__ + except Exception: + pass + try: + value = unicode(value) + return value.encode("ascii", "backslashreplace") + except Exception: + pass + return '<unprintable %s object>' % type(value).__name__ def print_exc(limit=None, file=None):
