inducer / pudb

Full-screen console debugger for Python
https://documen.tician.de/pudb/
Other
3k stars 230 forks source link

Redirection of output to a file causes pudb window to be small and squished #410

Closed zeeshansayyed closed 3 years ago

zeeshansayyed commented 4 years ago

According to the discussion here, any sort of redirection of output of a python script to another file, causes the pudb debugging window to be very small rendering it unusable.

When we remove the redirection, everything works as expected. Should this be filed as bug?

inducer commented 4 years ago

I'm not sure what you mean. Could you provide a minimal example of the behavior you're describing?

pyrrhull commented 3 years ago

I might have a related issue. When I resize the terminal (gnome-terminal) the view stays the same size although the window becomes bigger. After I move the cursor it becomes fullsize. It is weird as this only happens with pudb, not with other terminal programs ( I use ubuntu and i3 wm). pudb

inducer commented 3 years ago

@makrobios That's likely a separate bug. Could you make a new, separate issue?

asmeurer commented 3 years ago

Can you give a minimal reproducing example?

Most likely the redirection is breaking pudb's ability (or more likely, urwid's ability) to detect the terminal size, so it defaults to something like 20x80.

asmeurer commented 3 years ago

And I also agree that @makrobios's issue is different. That looks like urwid is not responding to WINCH signals correctly (both issues are probably urwid bugs, though I wouldn't rule out that pudb is somehow doing something to break them).

pyrrhull commented 3 years ago

@makrobios That's likely a separate bug. Could you make a new, separate issue?

Sure!

zeeshansayyed commented 3 years ago

Sorry for not providing an example earlier. Life happened and it kind of went off my to do list. Thanks @makrobios for bouncing this thread and reminding me. Here's an example.

Have a very simple python script in a file called pudb_test.py as follows:

import pudb

pu.db
print("Hello World")
print("This is a a pudb redirection test")
print("Test completed")

Now when you run this file with python pudb_test.py, everything works as expected.

But when you run this file and redirect its output, let's say using tee for example, as python pudb_test | tee -a output.txt, then the main pudb window is all squished as shown in the original stackoverflow question I posted. Here is the link to the image.

I hope you are able to reproduce it with this.

inducer commented 3 years ago

Thanks for clarifying. IMO, what you're trying cannot work, as pudb's stdout is not a pseudoterminal in that case, and thus the ioctls it would use to get the terminal size will not work.

zeeshansayyed commented 3 years ago

Thanks a lot @inducer In such cases, where I am debugging big projects which have redirections in them, what would be the best work around that you would use? In the project which I was working on, I ended up adding a debug flag which manually removed any/all redirections that were happening. It worked, but wasn't pretty us many log files stopped being printed. So for instance, could I manually change the window size when pudb starts?

inducer commented 3 years ago

https://documen.tician.de/pudb/starting.html#remote-debugging might help.