This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: traceback formatting can drop a frame
Type: behavior Stage: resolved
Components: Interpreter Core, Library (Lib) Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, miss-islington, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2018-09-05 17:52 by benjamin.peterson, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 9077 merged benjamin.peterson, 2018-09-06 06:03
PR 9134 merged miss-islington, 2018-09-10 15:43
PR 9135 merged miss-islington, 2018-09-10 15:43
Messages (7)
msg324648 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2018-09-05 17:52
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.
msg324663 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2018-09-06 05:54
Further investigation reveals this is a general off-by-one error with the recursive traceback pruning feature.
msg324827 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-09-08 10:17
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.
msg324858 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2018-09-08 19:01
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.
msg324926 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2018-09-10 15:43
New changeset d545869d084e70d4838310e79b52a25a72a1ca56 by Benjamin Peterson in branch 'master':
bpo-34588: Fix an off-by-one error in traceback formatting. (GH-9077)
https://github.com/python/cpython/commit/d545869d084e70d4838310e79b52a25a72a1ca56
msg324928 - (view) Author: miss-islington (miss-islington) Date: 2018-09-10 16:00
New changeset 49020174305ca3dc90a811b03a05f44873297c61 by Miss Islington (bot) in branch '3.7':
bpo-34588: Fix an off-by-one error in traceback formatting. (GH-9077)
https://github.com/python/cpython/commit/49020174305ca3dc90a811b03a05f44873297c61
msg324931 - (view) Author: miss-islington (miss-islington) Date: 2018-09-10 16:10
New changeset afb25bc2b5767ac3a83bc8c4d2826e8fdcb6b0e7 by Miss Islington (bot) in branch '3.6':
bpo-34588: Fix an off-by-one error in traceback formatting. (GH-9077)
https://github.com/python/cpython/commit/afb25bc2b5767ac3a83bc8c4d2826e8fdcb6b0e7
History
Date User Action Args
2022-04-11 14:59:05adminsetgithub: 78769
2018-09-10 16:10:25miss-islingtonsetnosy: + miss-islington
messages: + msg324931
2018-09-10 16:01:12benjamin.petersonsetstatus: open -> closed
nosy: - miss-islington

resolution: fixed
stage: patch review -> resolved
2018-09-10 16:00:13miss-islingtonsetnosy: + miss-islington
messages: + msg324928
2018-09-10 15:43:35miss-islingtonsetpull_requests: + pull_request8588
2018-09-10 15:43:27miss-islingtonsetpull_requests: + pull_request8587
2018-09-10 15:43:17benjamin.petersonsetmessages: + msg324926
2018-09-08 19:01:30benjamin.petersonsetmessages: + msg324858
2018-09-08 10:17:54serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg324827
2018-09-06 06:03:02benjamin.petersonsetkeywords: + patch
stage: patch review
pull_requests: + pull_request8535
2018-09-06 05:54:34benjamin.petersonsetmessages: + msg324663
components: + Interpreter Core
title: traceback module can drop a frame -> traceback formatting can drop a frame
2018-09-05 17:52:12benjamin.petersoncreate