Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

traceback.extract_tb breaks compatibility by returning FrameSummary #70689

Closed
encukou opened this issue Mar 7, 2016 · 7 comments
Closed

traceback.extract_tb breaks compatibility by returning FrameSummary #70689

encukou opened this issue Mar 7, 2016 · 7 comments
Labels
3.8 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@encukou
Copy link
Member

encukou commented Mar 7, 2016

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']

    @encukou
    Copy link
    Member Author

    encukou commented 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.

    @encukou encukou added the docs Documentation in the Doc dir label Mar 7, 2016
    @encukou encukou added the stdlib Python modules in the Lib dir label Mar 7, 2016
    @berkerpeksag
    Copy link
    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.

    @berkerpeksag berkerpeksag added the type-bug An unexpected behavior, bug, or error label Mar 8, 2016
    @bitdancer
    Copy link
    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.

    @bitdancer bitdancer reopened this Sep 9, 2016
    @encukou
    Copy link
    Member Author

    encukou commented Sep 10, 2018

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

    @berkerpeksag
    Copy link
    Member

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

    @berkerpeksag berkerpeksag added 3.8 (EOL) end of life and removed docs Documentation in the Doc dir labels Sep 11, 2018
    @encukou
    Copy link
    Member Author

    encukou commented 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
    Copy link
    Member

    Ok, let's close this issue then.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants