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
traceback.extract_tb breaks compatibility by returning FrameSummary #70689
Instead, since Python 3.5, it returns FrameSummary objects, which are not tuples, nor tuple subclasses, nor even sequences. (This broke some code in the wild that called len() on FrameSummary.)
bpo-25111 pointed out another tuple incompatibility, which was fixed. Should __len__ be added as well? Or the whole Sequence ABC?
I can provide a patch when those questions are answered.
This is basically a duplicate of bpo-25573. We need to add the examples in traceback module documentation to test_traceback.py.
Should __len__ be added as well?
IMO, the new FrameSummary API (and its friends) shouldn't change the return value of the existing traceback functions like extract_tb() so I'd say yes.
I disagree that this is a duplicate. The question here is, should we add __len__? Since a FrameSummary object can be "cast into a tuple" and has a known len, I would say the answer is definitely yes.
Activity
encukou commentedon Mar 7, 2016
According to the docs [0], traceback.extract_tb should return 4-tuples (filename, line number, function name, text).
[0] https://docs.python.org/3/library/traceback.html#traceback.extract_tb
Instead, since Python 3.5, it returns FrameSummary objects, which are not tuples, nor tuple subclasses, nor even sequences. (This broke some code in the wild that called len() on FrameSummary.)
bpo-25111 pointed out another tuple incompatibility, which was fixed. Should __len__ be added as well? Or the whole Sequence ABC?
I can provide a patch when those questions are answered.
berkerpeksag commentedon Mar 8, 2016
This is basically a duplicate of bpo-25573. We need to add the examples in traceback module documentation to test_traceback.py.
IMO, the new FrameSummary API (and its friends) shouldn't change the return value of the existing traceback functions like extract_tb() so I'd say yes.
bitdancer commentedon Sep 9, 2016
I disagree that this is a duplicate. The question here is, should we add __len__? Since a FrameSummary object can be "cast into a tuple" and has a known len, I would say the answer is definitely yes.
encukou commentedon Sep 10, 2018
New changeset 9797b7a by Petr Viktorin (Berker Peksag) in branch 'master':
bpo-26502: Implement FrameSummary.__len__() (GH-8632)
9797b7a
berkerpeksag commentedon Sep 11, 2018
Thanks for merging this, Petr. What do you think about backporting to 3.7?
encukou commentedon Sep 11, 2018
I don't think I have a good enough feel for what should, generally, go to 3.7. So take my opinion with a grain of salt.
But honestly, I don't think the issue is important enough -- I've only seen one codebase affected by it, which wasn't hard to fix.
berkerpeksag commentedon Sep 11, 2018
Ok, let's close this issue then.