(Asked a question on Stackoverflow with no luck, so retrying here, apologies if this breaks some protocol)
To summarize, I’m looking to understand what controls the pdb
reaction to the uparrow key to get the command history.
The context is that the pdb history works fine from the interpreter command prompt, but does work not when run through several layers of wrappers (pytest, pydevtool, doit, click). pytest --pdb
works fine.
Clearly, the issue is somewhere in these layers of wrappers, and I’m willing to look through them — the question is what to look for!
The OS is a bog-standard ubuntu linux, if that matters.
There are some SO questions which point to readline or pyreadline or gnureadline packages — e.g., Python pdb command history not working on Windows — pip installing gnureadline did not change anything, and import readline
seems to work.
To reproduce: drop a breakpoint somewhere
$ git diff
diff --git a/scipy/interpolate/tests/test_interpolate.py b/scipy/interpolate/tests/test_interpolate.py
index 1e22ff9c9d..f7500d0b5a 100644
--- a/scipy/interpolate/tests/test_interpolate.py
+++ b/scipy/interpolate/tests/test_interpolate.py
@@ -22,6 +22,10 @@ from scipy.integrate import nquad
from scipy.special import binom
+def test_pdb():
+ import pdb; pdb.set_trace()
+
+
class TestInterp2D:
And run the pydevtool-based CLI:
$ python dev.py test -t scipy/interpolate/tests/test_interpolate.py
💻 ninja -C /home/br/repos/scipy/scipy/build
ninja: Entering directory `/home/br/repos/scipy/scipy/build'
[2/2] Generating scipy/generate-config with a custom command
Build OK
💻 meson install -C build --only-changed
Installing, see meson-install.log...
Installation OK
SciPy from development installed path at: /home/br/repos/scipy/scipy/build-install/lib/python3.8/site-packages
Running tests for scipy version:1.10.0.dev0+2161.a637553, installed at:/home/br/repos/scipy/scipy/build-install/lib/python3.8/site-packages/scipy
================================= test session starts ==================================
platform linux -- Python 3.8.10, pytest-7.1.2, pluggy-1.0.0
rootdir: /home/br/repos/scipy/scipy, configfile: pytest.ini
collected 131 items
scipy/interpolate/tests/test_interpolate.py
>>>>>>>>>>>>>>>>>>>>>>> PDB set_trace (IO-capturing turned off) >>>>>>>>>>>>>>>>>>>>>>>>
--Return--
> /home/br/repos/scipy/scipy/build-install/lib/python3.8/site-packages/scipy/interpolate/tests/test_interpolate.py(26)test_pdb()->None
-> import pdb; pdb.set_trace()
(Pdb) import readline
(Pdb) <press the up arrow>^[[A
This scipy issue has the original context: doit based dev interface garbles pdb command history (in some cases) · Issue #16452 · scipy/scipy · GitHub
And the SO question is python - what controls pdb history (uparrow) - Stack Overflow
Any pointers would be much appreciated!