inducer / pudb

Full-screen console debugger for Python
https://documen.tician.de/pudb/
Other
2.99k stars 229 forks source link

When sys.argv be changed, pudb3 cannot enter REPL #545

Closed Freed-Wu closed 1 year ago

Freed-Wu commented 2 years ago

Describe the bug When sys.argv be changed, pudb3 cannot enter REPL

To Reproduce test.py

import sys
argv = sys.argv
sys.argv = []
print(1)
print(2)
print(3)
sys.argv = argv
print(4)
print(5)
print(6)

pudb3 test.py, when sys.argv is [], press ! cannot enter REPL. when sys.argv recovery, press ! can enter REPL.

Expected behavior press ! can enter REPL.

Additional context Can we backup sys.argv when the program start, And when we press ! recover sys.argv temporarily to avoid this bug?

Complete:

if some module of sys.modules (e.g, argparse) be changed, the same phenomenon will also happen.

inducer commented 2 years ago

When you say, "cannot enter the REPL", what's the symptom?

asmeurer commented 2 years ago

It probably depends on the REPL being used. IPython seems to work OK for me, but it does break other repls. This could perhaps be considered a bug in the specific repls, although I'm unclear why you would clear sys.argv like this. I would expect that in general that messing around with sys globals is going to break things.

Freed-Wu commented 2 years ago

but it does break other repls

I use ptpython.

what's the symptom

Press ! can not enter the ptpyhon's REPL.

I'm unclear why you would clear sys.argv like this

Some code do it and I just test and found this bug. :smile:

Freed-Wu commented 1 year ago

IPython seems to work OK for me, but it does break other repls

I have tested and found it seems that only ptpython has this problem. So I guess it is the bug of upstream.