New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
traceback attribute error #48284
Comments
Unrelated to this bug, I would like to have the ability to remove the So, periodically I test to see if python allows that. Python 2.6 gave 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'
>>> |
Here's a patch. It looks like traceback just needs to use a struct |
There seem to be some other exception type and string inconsistencies, >>> 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)
>>> tb.tb_frame.f_locals = None
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: attribute 'f_locals' of 'frame' objects is not writable
>>> tb.tb_frame.f_globals = None
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: readonly attribute
>>> dict.clear = "foo"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't set attributes of built-in/extension type 'dict' Should it be an AttributeError or TypeError? Should it be "read-only", Btw, here's the other ticket for the feature request: |
Instead of converting tb_frame attribute to read only, I prefer to marge$ ./python
Python 2.7a0 (trunk:66786M, Oct 7 2008, 00:48:32)
>>> try:
... a
... except:
... import sys
... t, v, tb = sys.exc_info()
...
>>> tb
<traceback object at 0xb7c76edc>
>>> tb.tb_frame
<frame object at 0x81cdbec>
>>> tb.tb_frame=42
>>> tb.tb_frame
42
>>> tb.tb_frame=None
>>> |
My patch causes a crash with: import sys
try:
raise Exception("hm!")
except:
t, v, tb = sys.exc_info()
tb.tb_frame = {}
raise t, v, tb Change tb.tb_frame value is not a good idea. It's better to clear |
One possibility would be to only allow deleting the tb_frame attribute |
Ping. benjamin.peterson's patch fixes the very strange issue, and I About clearing the frame/traceback, it's another issue (bpo-1565525). |
Fixed in r70463. |
@benjamin.peterson: Cool! Thanks. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: