pudb icon indicating copy to clipboard operation
pudb copied to clipboard

Debugger view raises error

Open gutsytechster opened this issue 5 months ago • 5 comments

Describe the bug When the logic flow reaches the import pudb; pu.db, it opens the debugger window, however, with an error at the bottom, i.e.

DEBUG pudb.debugger.ThreadsafeRawScreen.wait_for_input_ready Waiting for input: descriptors=[<socket.socket fd=4, family=1, type=1, proto=0>, <_io.TextIOWrapper name='<stdin>' mode='r' encoding='utf-8'>], timeout=None

This causes any key press to be unusable, which when pressed, the error keeps repeating.

To Reproduce Steps to reproduce the behavior:

Use import pudb; pu.db with Python 3.12.

Expected behavior The debugger view should be free from any error & any key press shouldn't propogate the error further.

Screenshots Image

Versions Python: 3.12.11 pudb: 2025.1

gutsytechster avatar Jul 22 '25 18:07 gutsytechster

As you can probably guess, I'm not able to reproduce this.

I'm guessing from the font that you might be using pudb on Windows. (Please confirm?) If so, I'm not sure to what extent Urwid supports Windows. Also, I'm not a Windows user and have limited ability to debug this.

Another possible angle is that these seem to be logging messages. We try to redirect those to the console:

https://github.com/inducer/pudb/blob/341c3c0c9660b13867d7dea1eb649725d3b4632e/pudb/lowlevel.py#L51-L93

I'm not sure why that's not working here.

Could you provide more context/a full reproducer?

inducer avatar Jul 26 '25 20:07 inducer

HI @inducer

No it's not windows. It's MacOS M4 Pro. I've recently switched to this system. But I've been using Fedora Linux previous to this & it was also present on that machine.

However, it was only reproducible in some python environment, while not in other. So my guess is that it's probably specific to python version or pudb version. I've mentioned both of these in initial issue description.

gutsytechster avatar Jul 28 '25 11:07 gutsytechster

However, it was only reproducible in some python environment

Can you tell me how to make a Python environment in which the problem occurs? Otherwise I feel I won't be able to adequately investigate this.

inducer avatar Jul 28 '25 16:07 inducer

Hi @inducer

Apparently in the same environment, an independent script doesn't raise this error, while when run through the program flow it raises it. The program flow goes through an async function. I initially thought it could be related to that, but unfortunately for an independent async code, as well, it doesn't behave like this.

It's only when it is executed within the execution flow of my program. I am not obliged to share that piece of code with you as it's proprietory. So far, it stopped repeating the same in the debugger window, but shows atleast 1 error at the bottom & repeat them in the terminal, whenever I press q or n.

Image

The initial set of error bombardment seems to have gone. This was all in Python 3.12.11 and with pudb 2025.1

gutsytechster avatar Jul 28 '25 19:07 gutsytechster

I had a similar problem and it was because my script was calling logging.basicConfig which was setting the default handler to output to sys.stderr. Then, inside of pudb, it is using the urwid module which seems to be using the default logging handlers. I was able to get around the problem by redirecting the stderr output in the shell when running my command

python3 -m pudb script.py args 2> stderr.log

mestar99 avatar Aug 01 '25 22:08 mestar99