You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Broken compatibility in FrameSummary equality #69298
Since 3.5 traceback.extract_tb() and traceback.extract_stack() return a list (actually list's subclass StackSummary) of FrameSummary objects instead of a list of tuples. FrameSummary is not fully compatible with tuple. One important incompatibility is in the comparing.
>>> import traceback
>>> traceback.extract_stack()[0] == ('<stdin>', 1, '<module>', '')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/serhiy/py/cpython-3.5/Lib/traceback.py", line 254, in __eq__
return (self.filename == other.filename and
AttributeError: 'tuple' object has no attribute 'filename'
In general __eq__ shouldn't raise an exception. bpo-25108 is needed to be fixed first for tests.
Here is a patch that restores compatibility.
An alternative solution would be to make FrameSummary a subclass of tuple (namedtuple).
Activity
serhiy-storchaka commentedon Sep 14, 2015
Since 3.5 traceback.extract_tb() and traceback.extract_stack() return a list (actually list's subclass StackSummary) of FrameSummary objects instead of a list of tuples. FrameSummary is not fully compatible with tuple. One important incompatibility is in the comparing.
In general __eq__ shouldn't raise an exception. bpo-25108 is needed to be fixed first for tests.
Here is a patch that restores compatibility.
An alternative solution would be to make FrameSummary a subclass of tuple (namedtuple).
serhiy-storchaka commentedon Sep 18, 2015
Fixed patch and added tests.
serhiy-storchaka commentedon Sep 27, 2015
Ping.
berkerpeksag commentedon Sep 28, 2015
LGTM
+ self.assertEqual(f, tuple(f))
+ self.assertEqual(tuple(f), f)
It would be good to add a comment to explain why we test both variants, but it's not really important.
vstinner commentedon Sep 29, 2015
traceback_FrameSummary_equality_2.patch looks good to me, but I have the same remark than Berker (see the review).
rbtcollins commentedon Sep 29, 2015
LGTM too.
python-dev commentedon Sep 29, 2015
New changeset 2ecb7d4d9e0b by Serhiy Storchaka in branch '3.5':
Issue bpo-25111: Fixed comparison of traceback.FrameSummary.
https://hg.python.org/cpython/rev/2ecb7d4d9e0b
New changeset f043182a81d7 by Serhiy Storchaka in branch 'default':
Issue bpo-25111: Fixed comparison of traceback.FrameSummary.
https://hg.python.org/cpython/rev/f043182a81d7