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
FrameSummary repr() does not support previously working uses of repr in traceback module #69759
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:
assignee=Noneclosed_at=Nonecreated_at=<Date2015-11-06.21:34:26.071>labels= ['3.8', '3.9', '3.10', 'docs']
title='FrameSummary repr() does not support previously working uses of repr in traceback module'updated_at=<Date2020-12-08.01:52:34.577>user='https://github.com/zopieux'
But actually, in 3.5+, this call outputs the repr() of a list of FrameSummary instances that do not go further in repr()esenting their state:
[<FrameSummary file <ipython-input-61-3e63d7daea82>, line 10 in <module>>,
By looking at the docs I thought I was able to get a nice string representation of a FrameSummary. I actually have to format it myself. It should be reflected in the doc sample output.
changed the title [-]traceback documentation example is lying about FrameSummary repr()[/-][+]FrameSummary repr() does not support previously working uses of repr in traceback module[/+]on Nov 6, 2015
Ah, I see there is. It is read lazily. It is an interesting question whether it should be read when the repr is printed...let's say no until/unless someone comes up with a good reason why it would be worthwhile.
I take it back. Since tuple(framesummary) produces all four elements, I think the repr should too. Likewise, in the __len__ issue I think it should always report 4.
So I think its fine to have a __len__ reporting 4. tuple(..) works via the iter() call, but thats really just a thunk to keep existing code working, and so __len__ for the same reason makes sense.
On the documentation issue, yes, updating the docs is appropriate.
Having the repr produce all the elements would be ok, the reason it is lazy is to avoid high costs for transient FrameSummary when its created and discarded shortly after.
I think the fourth element (the code line) was omitted from repr because it is not one of the constructor args for FrameSummary (it is derived from them), so it's redundant in terms of describing this instance.
Activity
zopieux commentedon Nov 6, 2015
https://docs.python.org/3.5/library/traceback.html#traceback-examples
See second code sample and its sample output. According to the docs, the call:
is supposed to print something that looks like an array with only strings; that is what the doc sample output states:
[('<doctest...>', 10, '<module>', 'lumberjack()'),
But actually, in 3.5+, this call outputs the repr() of a list of FrameSummary instances that do not go further in repr()esenting their state:
[<FrameSummary file <ipython-input-61-3e63d7daea82>, line 10 in <module>>,
By looking at the docs I thought I was able to get a nice string representation of a FrameSummary. I actually have to format it myself. It should be reflected in the doc sample output.
bitdancer commentedon Nov 6, 2015
IMO, that is neither a lie nor a doc bug, it is a bug in the new traceback features that were added in 3.5.
[-]traceback documentation example is lying about FrameSummary repr()[/-][+]FrameSummary repr() does not support previously working uses of repr in traceback module[/+]matrixise commentedon Nov 6, 2015
Could you check with Python 3.4 ?
matrixise commentedon Nov 6, 2015
Oops, sorry,
torsava commentedon Aug 30, 2016
This problem has already been addressed in bpo-27208, and it was fixed by updating the documentation to reflect the new repr().
Therefore, I believe this issue can be closed.
bitdancer commentedon Sep 9, 2016
Is there a reason the fourth element of the tuple is not included in the FrameSummary repr? Otherwise I agree that this could be closed.
bitdancer commentedon Sep 9, 2016
Ah, I see there is. It is read lazily. It is an interesting question whether it should be read when the repr is printed...let's say no until/unless someone comes up with a good reason why it would be worthwhile.
bitdancer commentedon Sep 9, 2016
I take it back. Since tuple(framesummary) produces all four elements, I think the repr should too. Likewise, in the __len__ issue I think it should always report 4.
Let see if other devs agree.
rbtcollins commentedon Sep 12, 2016
So I think its fine to have a __len__ reporting 4. tuple(..) works via the iter() call, but thats really just a thunk to keep existing code working, and so __len__ for the same reason makes sense.
On the documentation issue, yes, updating the docs is appropriate.
Having the repr produce all the elements would be ok, the reason it is lazy is to avoid high costs for transient FrameSummary when its created and discarded shortly after.
iritkatriel commentedon Nov 4, 2020
I think the fourth element (the code line) was omitted from repr because it is not one of the constructor args for FrameSummary (it is derived from them), so it's redundant in terms of describing this instance.