Skip to content

FrameSummary repr() does not support previously working uses of repr in traceback module #69759

Closed

Description

@zopieux
mannequin
BPO 25573
Nosy @rbtcollins, @bitdancer, @berkerpeksag, @matrixise, @zopieux, @torsava, @iritkatriel

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 = None
closed_at = None
created_at = <Date 2015-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 = <Date 2020-12-08.01:52:34.577>
user = 'https://github.com/zopieux'

bugs.python.org fields:

activity = <Date 2020-12-08.01:52:34.577>
actor = 'iritkatriel'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Documentation']
creation = <Date 2015-11-06.21:34:26.071>
creator = 'zopieux'
dependencies = []
files = []
hgrepos = []
issue_num = 25573
keywords = ['patch', '3.5regression']
message_count = 10.0
messages = ['254224', '254228', '254230', '254234', '273931', '275355', '275371', '275375', '275896', '380334']
nosy_count = 8.0
nosy_names = ['rbcollins', 'r.david.murray', 'docs@python', 'berker.peksag', 'matrixise', 'zopieux', 'torsava', 'iritkatriel']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'patch review'
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue25573'
versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

Activity

  1. zopieux commented on Nov 6, 2015

    zopieuxmannequin
    MannequinAuthor

    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:

      print(repr(traceback.extract_tb(exc_traceback)))

    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.

  2. bitdancer commented on Nov 6, 2015

    @bitdancer
    Member

    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.

  3. 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
  4. matrixise commented on Nov 6, 2015

    @matrixise
    Member

    Could you check with Python 3.4 ?

  5. matrixise commented on Nov 6, 2015

    @matrixise
    Member

    Oops, sorry,

  6. torsava commented on Aug 30, 2016

    torsavamannequin
    Mannequin

    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.

  7. bitdancer commented on Sep 9, 2016

    @bitdancer
    Member

    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.

  8. bitdancer commented on Sep 9, 2016

    @bitdancer
    Member

    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.

  9. bitdancer commented on Sep 9, 2016

    @bitdancer
    Member

    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.

  10. rbtcollins commented on Sep 12, 2016

    @rbtcollins
    Member

    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.

  11. iritkatriel commented on Nov 4, 2020

    @iritkatriel
    Member

    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.

  12. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions