In REPL `dis.distb()` raise AttributeError when the previous input fails to compile
Open
Nobody has claimed this yet.
stdlib
topic-repl
type-bug
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug report
Bug description:
in REPL input following sequentially
import dis- some invalid code
dis.distb()
>>> import dis
>>> ???
File "<stdin>", line 1
???
^
SyntaxError: invalid syntax
>>> dis.distb()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
dis.distb()
~~~~~~~~~^^
File "/home/dev/cpython/Lib/dis.py", line 150, in distb
while tb.tb_next: tb = tb.tb_next
^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'tb_next'
It looks like dis.distb() doesn’t handle the case where the previous exception’s traceback could be None in the REPL.
CPython versions tested on:
3.14, CPython main branch
Operating systems tested on:
Windows
Linked PRs
- gh-148317
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at Lib/dis.py around dis.distb() line 150 and reproduce the reported REPL sequence: import dis, enter invalid code, then call dis.distb(). Done means the final command no longer raises AttributeError after the preceding compilation failure; check the linked gh-148317 work before starting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100