[Patches] [Patch #100851] traceback.py, with unicode exceptions

noreply@sourceforge.net noreply@sourceforge.net
Thu, 27 Jul 2000 13:25:22 -0700


Patch #100851 has been updated. 

Project: 
Category: None
Status: Rejected
Summary: traceback.py, with unicode exceptions

Follow-Ups:

Date: 2000-Jul-11 03:58
By: htrd

Comment:
traceback.py can format an exception as a string - but what happens when an exception is raised during the string conversion?

In this case it is better to discard the inner exception, to allow the original exception to be reported.

The migration to unicode strings makes this quite common. Old code might report a failue with something like....
raise IWasntExpectingThisError('nobody expects %s' % x)

An alternative fix is to change __str__ for exceptions to handle the exception. This would be neater, but I chose to follow the example set by PyErr_PrintEx which has a comment:
/* If an error happened here, don't show it.
   XXX This is wrong, but too many callers rely on this behavior. */

-------------------------------------------------------

Date: 2000-Jul-27 13:25
By: gvanrossum

Comment:
Actually I like this, but instead of the id() of the value you should show its type, e.g. "<unprintable %s object>" % type(value).
-------------------------------------------------------

-------------------------------------------------------
For more info, visit:

http://sourceforge.net/patch/?func=detailpatch&patch_id=100851&group_id=5470