[Python-Dev] traceback.py still broken in 2.5a2

Guido van Rossum guido at python.org
Thu Apr 27 20:38:48 CEST 2006


The change below was rolled back because it broke other stuff. But IMO
it is actually necessary to fix this, otherwise those few exceptions
that don't derive from Exception won't be printed correctly by the
traceback module:

guido:~/p/osx guido$ ./python.exe
Python 2.5a2 (trunk:45765, Apr 27 2006, 11:36:10)
[GCC 4.0.0 20041026 (Apple Computer, Inc. build 4061)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> def f():
...   raise KeyboardInterrupt
...
>>> f()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in f
KeyboardInterrupt
>>> import traceback
>>> try:
...   f()
... except:
...   traceback.print_exc()
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "<stdin>", line 2, in f
<class 'exceptions.KeyboardInterrupt'>
>>>

--Guido

---------- Forwarded message ----------
From: phillip.eby <python-checkins at python.org>
Date: Mar 24, 2006 3:10 PM
Subject: [Python-checkins] r43299 - python/trunk/Lib/traceback.py
To: python-checkins at python.org


Author: phillip.eby
Date: Fri Mar 24 23:10:54 2006
New Revision: 43299

Modified:
   python/trunk/Lib/traceback.py
Log:
Revert r42719, because the isinstance() check wasn't redundant; formatting a
string exception was causing a TypeError.


Modified: python/trunk/Lib/traceback.py
==============================================================================
--- python/trunk/Lib/traceback.py       (original)
+++ python/trunk/Lib/traceback.py       Fri Mar 24 23:10:54 2006
@@ -158,7 +158,7 @@
     """
     list = []
     if (type(etype) == types.ClassType
-        or issubclass(etype, Exception)):
+        or (isinstance(etype, type) and issubclass(etype, Exception))):
         stype = etype.__name__
     else:
         stype = etype
_______________________________________________
Python-checkins mailing list
Python-checkins at python.org
http://mail.python.org/mailman/listinfo/python-checkins


--
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list