[Python-checkins] r43299 - python/trunk/Lib/traceback.py

Guido van Rossum guido at python.org
Thu Apr 13 17:58:07 CEST 2006


In any case, one part of the recently debated and rolled-back change
by georg should be reinstated: the issubclass() check should mention
BaseException. Test case that is now broken:

>>> try: raise KeyboardInterrupt
... except: import traceback; traceback.print_exc()
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
<class 'exceptions.KeyboardInterrupt'>
>>>

This should have printed KeyboardInterrupt instead of <class
'exceptions.KeyboardInterrupt'>.

--Guido

On 4/13/06, Neal Norwitz <nnorwitz at gmail.com> wrote:
> ping
>
> On 3/24/06, Neal Norwitz <nnorwitz at gmail.com> wrote:
> > How about a test case?
> >
> > Is this just for strings?  If so, should you just check for basestring instead of type?
> >
> > n
> > --
> >
> > On 3/24/06, phillip.eby <python-checkins at python.org> wrote:
> > > 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
> > >
> >
> _______________________________________________
> 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-checkins mailing list