[New-bugs-announce] [issue4034] traceback attribute error

Greg Hazel report at bugs.python.org
Sat Oct 4 01:31:59 CEST 2008


New submission from Greg Hazel <ghazel at users.sourceforge.net>:

Unrelated to this bug, I would like to have the ability to remove the 
reference to the frame from the traceback object. Specifically so that 
the traceback object could be stored for a while without keeping all 
the locals alive as well.

So, periodically I test to see if python allows that. Python 2.6 gave 
some strange results compared to 2.5.2:

Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> try:
...     x = dskjfds
... except:
...     import sys
...     t, v, tb = sys.exc_info()
...
>>> tb
<traceback object at 0x01396670>
>>> dir(tb)
['tb_frame', 'tb_lasti', 'tb_lineno', 'tb_next']
>>> tb.tb_frame
<frame object at 0x01371598>
>>> tb.tb_frame = None
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'traceback' object has only read-only attributes (assign 
to .tb_frame)
>>>


Python 2.6 (r26:66721, Oct  2 2008, 11:35:03) [MSC v.1500 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> try:
...     x = lfdskf
... except:
...     import sys
...     t, v, tb = sys.exc_info()
...
>>> tb
<traceback object at 0x01581F80>
>>> dir(tb)
['tb_frame', 'tb_lasti', 'tb_lineno', 'tb_next']
>>> tb.tb_frame
<frame object at 0x013B9E10>
>>> tb.tb_frame = None
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'traceback' object has no attribute 'tb_frame'
>>>

----------
messages: 74282
nosy: ghazel
severity: normal
status: open
title: traceback attribute error
type: behavior
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4034>
_______________________________________


More information about the New-bugs-announce mailing list