pudb icon indicating copy to clipboard operation
pudb copied to clipboard

When sys.argv be changed, pudb3 cannot enter REPL

Open Freed-Wu opened this issue 3 years ago • 3 comments

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.

Freed-Wu avatar Aug 23 '22 14:08 Freed-Wu

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

inducer avatar Aug 23 '22 15:08 inducer

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.

asmeurer avatar Aug 23 '22 23:08 asmeurer

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 avatar Aug 24 '22 02:08 Freed-Wu

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.

Freed-Wu avatar Jan 20 '23 14:01 Freed-Wu