-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-102980: Redirect pdb interact command, add tests and improve docs
#111194
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
Conversation
interact command, add tests and improve docs
|
Hi @iritkatriel , could you maybe take a look at this PR when you have some time? It's a relatively straightforward one and it's been stuck for a while. Thanks! |
| @@ -0,0 +1 @@ | |||
| Redirect the output of ``interact`` command of :mod:`pdb` to the same channel as the debugger. Add tests and improve docs. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this describing the code change in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. So currently pdb uses code.interact directly for interact command. However, code.interact has a hard-coded output to sys.stderr. pdb supports defining output channel, and we kind of use that for our tests. The user would also expect the output from interact command flushed to the same channel as pdb (stdout instead of stderr by default actually).
This PR subclassed code.InteractiveConsole to overwrite the write method, in order to redirect the output to self.message.
|
Thanks for the review! |
…ts and improve docs (python#111194)
…ts and improve docs (python#111194)
With the long due #102896, we can finally add tests for
interactcommand.However, the current
interactcommand usescode.interactdirectly which makes it super difficult to test, becausecode.interactwrites tosys.stderrdirectly (withsys.stderr.write)! We need to overload thewritemethod in a derived class to write to the same channel asPdb.message.The interactive message is also changed to make more sense - one might wonder if this is a breaking change to users, but
interactcommand, so I don't think we'll break anything.This PR adds the class for interact commmand and some basic tests for
interact; and also clarifies the namespace situation withinteract- it's a bit tricky and could be confusing to the users, so some clarification is needed.The way to exit
interactcommand is also added to the docs.📚 Documentation preview 📚: https://cpython-previews--111194.org.readthedocs.build/