Issue 26502: traceback.extract_tb breaks compatibility by returning FrameSummary (original) (raw)

Created on 2016-03-07 11:15 by petr.viktorin, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 8632 merged berker.peksag,2018-08-02 17:46
Messages (7)
msg261296 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2016-03-07 11:15
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.) Issue 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.
msg261357 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-03-08 12:52
This is basically a duplicate of issue 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.
msg275356 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2016-09-09 17:35
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.
msg324937 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2018-09-10 17:02
New changeset 9797b7ae4496627836c55333765e10201a9840e3 by Petr Viktorin (Berker Peksag) in branch 'master': bpo-26502: Implement FrameSummary.__len__() (GH-8632) https://github.com/python/cpython/commit/9797b7ae4496627836c55333765e10201a9840e3
msg325036 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2018-09-11 17:33
Thanks for merging this, Petr. What do you think about backporting to 3.7?
msg325038 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2018-09-11 17:49
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.
msg325040 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2018-09-11 17:54
Ok, let's close this issue then.
History
Date User Action Args
2022-04-11 14:58:28 admin set github: 70689
2018-09-11 17:54:10 berker.peksag set status: open -> closedversions: - Python 3.5, Python 3.6messages: + resolution: fixedstage: patch review -> resolved
2018-09-11 17:49:10 petr.viktorin set messages: +
2018-09-11 17:33:43 berker.peksag set messages: + components: - Documentationversions: + Python 3.8
2018-09-10 17:02:36 petr.viktorin set messages: +
2018-08-02 17:46:45 berker.peksag set keywords: + patchstage: needs patch -> patch reviewpull_requests: + <pull%5Frequest8137>
2016-09-09 17:35:14 r.david.murray set status: closed -> opennosy: + r.david.murraymessages: + resolution: duplicate -> (no value)stage: resolved -> needs patch
2016-03-08 12:52:51 berker.peksag set status: open -> closedtype: behaviornosy: + berker.peksagmessages: + resolution: duplicatestage: resolved
2016-03-08 12:36:47 vstinner set nosy: + rbcollins
2016-03-07 11:15:48 petr.viktorin create