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 formatting can drop a frame #78769

Closed
benjaminp opened this issue Sep 5, 2018 · 7 comments
Closed

traceback formatting can drop a frame #78769

benjaminp opened this issue Sep 5, 2018 · 7 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@benjaminp
Copy link
Contributor

BPO 34588
Nosy @benjaminp, @serhiy-storchaka, @miss-islington
PRs
  • closes bpo-34588: Fix an off-by-one error in traceback formatting. #9077
  • [3.7] bpo-34588: Fix an off-by-one error in traceback formatting. (GH-9077) #9134
  • [3.6] bpo-34588: Fix an off-by-one error in traceback formatting. (GH-9077) #9135
  • 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-10.16:01:12.044>
    created_at = <Date 2018-09-05.17:52:12.246>
    labels = ['interpreter-core', '3.8', 'type-bug', 'library', '3.7']
    title = 'traceback formatting can drop a frame'
    updated_at = <Date 2018-09-10.16:10:25.501>
    user = 'https://github.com/benjaminp'

    bugs.python.org fields:

    activity = <Date 2018-09-10.16:10:25.501>
    actor = 'miss-islington'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-09-10.16:01:12.044>
    closer = 'benjamin.peterson'
    components = ['Interpreter Core', 'Library (Lib)']
    creation = <Date 2018-09-05.17:52:12.246>
    creator = 'benjamin.peterson'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 34588
    keywords = ['patch']
    message_count = 7.0
    messages = ['324648', '324663', '324827', '324858', '324926', '324928', '324931']
    nosy_count = 3.0
    nosy_names = ['benjamin.peterson', 'serhiy.storchaka', 'miss-islington']
    pr_nums = ['9077', '9134', '9135']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue34588'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

    @benjaminp
    Copy link
    Contributor Author

    Consider the following script:
    import traceback

    def fill_stack(depth):
        if depth <= 1:
            return traceback.format_stack()
        else:
            return fill_stack(depth - 1)

    assert fill_stack(4) != fill_stack(5)

    On the Python 3 versions I tested, this script doesn't fail! Somehow traceback is producing identical tracebacks for different callstacks.

    @benjaminp benjaminp added 3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Sep 5, 2018
    @benjaminp
    Copy link
    Contributor Author

    Further investigation reveals this is a general off-by-one error with the recursive traceback pruning feature.

    @benjaminp benjaminp added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Sep 6, 2018
    @benjaminp benjaminp changed the title traceback module can drop a frame traceback formatting can drop a frame Sep 6, 2018
    @serhiy-storchaka
    Copy link
    Member

    In case of 4 repeated lines it doesn't make much sense to output 3 repeated lines and replace the forth line with "Previous line repeated 1 more time". This doesn't save space and doesn't help reading the traceback. I think it is better to output the forth repeated line.

    @benjaminp
    Copy link
    Contributor Author

    It actually does save space because each traceback entry is usually two lines (frame id and source snippet).

    I don't really have an opinion about what should happen be printed on the boundary cases. My current PR seems like a strict improvement to the current implementation, which is just incorrect.

    @benjaminp
    Copy link
    Contributor Author

    New changeset d545869 by Benjamin Peterson in branch 'master':
    bpo-34588: Fix an off-by-one error in traceback formatting. (GH-9077)
    d545869

    @miss-islington
    Copy link
    Contributor

    New changeset 4902017 by Miss Islington (bot) in branch '3.7':
    bpo-34588: Fix an off-by-one error in traceback formatting. (GH-9077)
    4902017

    @miss-islington
    Copy link
    Contributor

    New changeset afb25bc by Miss Islington (bot) in branch '3.6':
    bpo-34588: Fix an off-by-one error in traceback formatting. (GH-9077)
    afb25bc

    @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.7 (EOL) end of life 3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) 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