zope.exceptions.exceptionformatter and non-ASCII characters

Bug #98389 reported by Marius Gedminas
4
Affects Status Importance Assigned to Milestone
Zope 3
Won't Fix
Low
Unassigned
zope.exceptions
Won't Fix
Low
Unassigned

Bug Description

I used zope.exceptions.exceptionformatter.format_exception (as_html=False) in an application to show tracebacks in views. I have encountered situations when format_exception returned me a list of UTF-8 strings (my system locale is UTF-8), other situations where I got a list of Unicode strings, and even situations where the list contained a mixture of UTF-8 and Unicode strings (causing UnicodeDecodeErrors in ''.join(...)).

The contract of the exception formatter should explicitly say whether it returns Unicode or not, and various formatting methods should take care to convert the strings as appropriate. I would prefer to get Unicode always.

Source of 8-bit characters: linecache.getline, traceback.format_exception_only. Suspected source of Unicode strings: __traceback_info__/__traceback_supplement__.

There are some calls to str() and, log.Formatter uses cStringIO -- these would break with Unicode strings.

(Side issue: TextExceptionFormatter also sometimes performs HTML escaping.)

Tags: core issue
Tres Seaver (tseaver)
Changed in zope.exceptions:
assignee: nobody → Marius Gedminas (mgedmin)
importance: Undecided → Low
status: New → Confirmed
Changed in zope3:
status: Confirmed → Won't Fix
Changed in zope3:
assignee: Marius Gedminas (mgedmin) → nobody
Changed in zope.exceptions:
assignee: Marius Gedminas (mgedmin) → nobody
Revision history for this message
Marius Gedminas (mgedmin) wrote :

Incidentally, there's interesting code in zope.error where it tries to cope with this issue and force everything into ASCII.

Revision history for this message
Tres Seaver (tseaver) wrote :
Changed in zope.exceptions:
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.