[Python-Dev] Traceback object has no class? (original) (raw)

Nick Coghlan ncoghlan at gmail.com
Mon Apr 12 08:56:18 CEST 2010


Greg Ewing wrote:

I thought type-class unification was supposed to mean that all objects now have a class attribute. But traceback objects don't seem to:

import sys try: raise ValueError except ValueError: tb = sys.excinfo()[2] print tb print tb.class

I'm not sure what build you're getting that behaviour on, but my svn build of 2.6 has a class attribute for traceback objects, as does the kubuntu 9.10 python 2.6.4 system install.

try: ... raise ValueError ... except: ... import sys ... tb = sys.exc_info()[2] ... print type(tb) ... print dir(tb) ... print tb.class ... <type 'traceback'> ['class', 'delattr', 'doc', 'format', 'getattribute', 'hash', 'init', 'new', 'reduce', 'reduce_ex', 'repr', 'setattr', 'sizeof', 'str', 'subclasshook', 'tb_frame', 'tb_lasti', 'tb_lineno', 'tb_next'] <type 'traceback'>

Cheers, Nick.

-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia



More information about the Python-Dev mailing list