Skip to content

Traceback module fails when offering a builtin name suggestion #98878

Closed
@isidentical

Description

@isidentical

Bug report

import traceback try: prnt("Hello!") except Exception: traceback.print_exc()
Traceback (most recent call last): File "/home/seaworth/projects/cpython/t.py", line 5, in <module> prnt("Hello!") ^^^^ NameError: name 'prnt' is not defined. Did you mean: 'print'? During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/seaworth/projects/cpython/t.py", line 7, in <module> traceback.print_exc() File "/home/seaworth/projects/cpython/Lib/traceback.py", line 183, in print_exc print_exception(*sys.exc_info(), limit=limit, file=file, chain=chain) File "/home/seaworth/projects/cpython/Lib/traceback.py", line 124, in print_exception te = TracebackException(type(value), value, tb, limit=limit, compact=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/seaworth/projects/cpython/Lib/traceback.py", line 716, in __init__ suggestion = _compute_suggestion_error(exc_value, exc_traceback, wrong_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/seaworth/projects/cpython/Lib/traceback.py", line 1038, in _compute_suggestion_error + list(frame.f_globals['__builtins__']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: 'module' object is not iterable

Your environment

Latest revision of CPython

Metadata

Metadata

Assignees

Labels

type-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions