0

What controls the pdb reaction to the uparrow to get the command history?

The context is that pdb history works fine from the interpreter command prompt, but does not when run through several layers of wrappers (pytest, pydevtool, doit, click). pytest --pdb works fine.

I'd like to understand where to even start looking and for what.

More context is at this scipy issue: https://github.com/scipy/scipy/issues/16452

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
ev-br
  • 24,968
  • 9
  • 65
  • 78

0 Answers0