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 module fails when offering a builtin name suggestion #98878

Closed
isidentical opened this issue Oct 30, 2022 · 0 comments
Closed

Traceback module fails when offering a builtin name suggestion #98878

isidentical opened this issue Oct 30, 2022 · 0 comments
Assignees
Labels
type-bug An unexpected behavior, bug, or error

Comments

@isidentical
Copy link
Sponsor Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant