mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue #8313: traceback.format_exception_only() encodes unicode message to
ASCII with backslashreplace error handler if str(value) failed
This commit is contained in:
parent
f3c157f639
commit
926fd4ee32
3 changed files with 20 additions and 2 deletions
|
@ -211,8 +211,14 @@ def _format_final_exc_line(etype, value):
|
|||
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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue