homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Broken compatibility in FrameSummary equality
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: berker.peksag, python-dev, rbcollins, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2015年09月14日 17:48 by serhiy.storchaka, last changed 2022年04月11日 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
traceback_FrameSummary_equality.patch serhiy.storchaka, 2015年09月14日 17:49 review
traceback_FrameSummary_equality_2.patch serhiy.storchaka, 2015年09月18日 07:23 review
Messages (7)
msg250693 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015年09月14日 17:48
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. Issue25108 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).
msg250953 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015年09月18日 07:23
Fixed patch and added tests.
msg251722 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015年09月27日 20:11
Ping.
msg251760 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2015年09月28日 11:19
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.
msg251834 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015年09月29日 09:49
traceback_FrameSummary_equality_2.patch looks good to me, but I have the same remark than Berker (see the review).
msg251835 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2015年09月29日 09:51
LGTM too.
msg251880 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015年09月29日 19:36
New changeset 2ecb7d4d9e0b by Serhiy Storchaka in branch '3.5':
Issue #25111: Fixed comparison of traceback.FrameSummary.
https://hg.python.org/cpython/rev/2ecb7d4d9e0b
New changeset f043182a81d7 by Serhiy Storchaka in branch 'default':
Issue #25111: Fixed comparison of traceback.FrameSummary.
https://hg.python.org/cpython/rev/f043182a81d7 
History
Date User Action Args
2022年04月11日 14:58:21adminsetgithub: 69298
2015年09月29日 19:37:09serhiy.storchakasetstatus: open -> closed
assignee: serhiy.storchaka
resolution: fixed
stage: commit review -> resolved
2015年09月29日 19:36:33python-devsetnosy: + python-dev
messages: + msg251880
2015年09月29日 09:51:29rbcollinssetmessages: + msg251835
2015年09月29日 09:49:21vstinnersetnosy: + vstinner
messages: + msg251834
2015年09月28日 11:19:13berker.peksagsetnosy: + berker.peksag

messages: + msg251760
stage: patch review -> commit review
2015年09月27日 20:11:09serhiy.storchakasetmessages: + msg251722
2015年09月18日 07:23:20serhiy.storchakasetfiles: + traceback_FrameSummary_equality_2.patch

messages: + msg250953
2015年09月14日 17:49:00serhiy.storchakasetfiles: + traceback_FrameSummary_equality.patch
keywords: + patch
2015年09月14日 17:48:43serhiy.storchakacreate

AltStyle によって変換されたページ (->オリジナル) /