Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boltons.ecoutils 23.0.0 breaks pdb interactive prompt in pytest debug sessions #334

Open
kdeldycke opened this issue Apr 8, 2023 · 4 comments

Comments

@kdeldycke
Copy link
Contributor

kdeldycke commented Apr 8, 2023

I've got a really strange issue.

Tl;Dr: when I import from boltons.ecoutils import get_profile from boltons 23.0.0, the interactive pdb prompt from my pytest --pdb calls disappears.

Before the upgrade to 23.0.0, I had:

$ poetry run pytest --pdb
================= test session starts =================
platform darwin -- Python 3.11.2, pytest-7.2.1, pluggy-1.0.0
Using --randomly-seed=1875232546
plugins: cases-3.6.13, randomly-3.12.0, cov-4.0.0, httpserver-1.0.6
(...)
click_extra/tests/test_colorize.py 
>>>>>>> PDB set_trace (IO-capturing turned off) >>>>>>>
--Call--
> .../lib/python3.11/site-packages/click/testing.py(133)output()
-> @property
(Pdb) 

After the upgrade to 23.0.0, I get a blocking prompt:

$ poetry run pytest --pdb
================= test session starts =================
platform darwin -- Python 3.11.2, pytest-7.2.1, pluggy-1.0.0
Using --randomly-seed= 1875232546
plugins: cases-3.6.13, randomly-3.12.0, cov-4.0.0, httpserver-1.0.6
(...)
click_extra/tests/test_colorize.py 
>>>>>>> PDB set_trace (IO-capturing turned off) >>>>>>>
--Call--
> .../lib/python3.11/site-packages/click/testing.py(133)output()
-> @property

See above the blocking pdb session without any prompt. It is not responding to any pdb command and have to exits with ^D.

And in the configuration above, as soon as I remove the from boltons.ecoutils import get_profile statement from my code, while keeping the 23.0.0 version of boltons installed, then the problem disappear and I get back my interactive pdb prompt.

I confirm this issue to be completely absent from the 21.0.0 release of boltons.

For reference, the issue appeared in my project with commit: kdeldycke/click-extra@1f7c6de

As for the potential fix, there something wrong with the changes in boltons/ecoutils.py between 21.0.0 and 23.0.0: 21.0.0...23.0.0#diff-71d9829db55b3d86e1aefcc41e09ab86f3de1d42db1d9859f9976413f0315c86 . Probably with the way pprint._safe_repr is monkey-patched.

@kdeldycke kdeldycke changed the title boltons.ecoutils 23.0.0 breaks pdb interactive prompt in pytest debug sessions boltons.ecoutils v23.0.0 breaks pdb interactive prompt in pytest debug sessions Apr 8, 2023
@kdeldycke kdeldycke changed the title boltons.ecoutils v23.0.0 breaks pdb interactive prompt in pytest debug sessions boltons.ecoutils 23.0.0 breaks pdb interactive prompt in pytest debug sessions Apr 8, 2023
@kdeldycke
Copy link
Contributor Author

OK, I think I found the root cause. A fix is proposed at: #335

kdeldycke added a commit to kdeldycke/click-extra that referenced this issue Apr 8, 2023
@kdeldycke
Copy link
Contributor Author

Forget about my patch proposed in #335. The real culprit is readline. I missed it as my code editor made some linting changes behind my back.

So, to sum it up, this patch fix the issue described here:

diff --git boltons/ecoutils.py boltons/ecoutils.py
index c5ff16a..6bf3367 100644
--- boltons/ecoutils.py
+++ boltons/ecoutils.py
@@ -180,7 +180,7 @@ HAVE_UCS4 = getattr(sys, 'maxunicode', 0) > 65536
 HAVE_READLINE = True
 
 try:
-    import readline
+    pass
 except Exception:
     HAVE_READLINE = False
 

Of course this is not an acceptable change to push as-is to upstream, as we loose the readline detection. But at least I found the culprit.

I'll try to dig for a root cause in that direction. In the mean time, here is the system I'm running:

  • Python 3.11.3
  • macOS Ventura 13.3.1
  • readline: stable 8.2.1 (bottled) [keg-only] (installed via brew)

@mahmoud
Copy link
Owner

mahmoud commented Apr 9, 2023

Veeeerry interesting. readline has always been a tricky one. I don't have any immediate workarounds that come to mind, but I'm looking forward to anything else you find.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants