Skip to content

traceback.extract_tb breaks compatibility by returning FrameSummary #70689

Closed

Description

@encukou
BPO 26502
Nosy @rbtcollins, @bitdancer, @encukou, @berkerpeksag
PRs
  • bpo-26502: Implement FrameSummary.__len__() #8632
  • 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 = <Date 2018-09-11.17:54:10.821>
    created_at = <Date 2016-03-07.11:15:48.241>
    labels = ['3.8', 'type-bug', 'library']
    title = 'traceback.extract_tb breaks compatibility by returning FrameSummary'
    updated_at = <Date 2018-09-11.17:54:10.819>
    user = 'https://github.com/encukou'

    bugs.python.org fields:

    activity = <Date 2018-09-11.17:54:10.819>
    actor = 'berker.peksag'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2018-09-11.17:54:10.821>
    closer = 'berker.peksag'
    components = ['Library (Lib)']
    creation = <Date 2016-03-07.11:15:48.241>
    creator = 'petr.viktorin'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 26502
    keywords = ['patch']
    message_count = 7.0
    messages = ['261296', '261357', '275356', '324937', '325036', '325038', '325040']
    nosy_count = 5.0
    nosy_names = ['rbcollins', 'r.david.murray', 'petr.viktorin', 'docs@python', 'berker.peksag']
    pr_nums = ['8632']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue26502'
    versions = ['Python 3.8']

    Activity

    1. encukou commented on Mar 7, 2016

      @encukou
      MemberAuthor

      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.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Mar 7, 2016
    3. berkerpeksag commented on Mar 8, 2016

      @berkerpeksag
      Member

      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.

    4. bitdancer commented on Sep 9, 2016

      @bitdancer
      Member

      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.

    5. encukou commented on Sep 10, 2018

      @encukou
      MemberAuthor

      New changeset 9797b7a by Petr Viktorin (Berker Peksag) in branch 'master':
      bpo-26502: Implement FrameSummary.__len__() (GH-8632)
      9797b7a

    6. berkerpeksag commented on Sep 11, 2018

      @berkerpeksag
      Member

      Thanks for merging this, Petr. What do you think about backporting to 3.7?

    7. added and removed
      docsDocumentation in the Doc dir
      on Sep 11, 2018
    8. encukou commented on Sep 11, 2018

      @encukou
      MemberAuthor

      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.

    9. berkerpeksag commented on Sep 11, 2018

      @berkerpeksag
      Member

      Ok, let's close this issue then.

    10. 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

      3.8 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions