Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
gh-102980: Redirect pdbinteract 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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
interact command, add tests and improve docsHi@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 currentlypdb usescode.interact directly forinteract command. However,code.interact has a hard-coded output tosys.stderr.pdb supports defining output channel, and we kind of use that for our tests. The user would also expect the output frominteract command flushed to the same channel aspdb (stdout instead of stderr by default actually).
This PR subclassedcode.InteractiveConsole to overwrite thewrite method, in order to redirect the output toself.message.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Thanks for the review! |
…ts and improve docs (python#111194)
…ts and improve docs (python#111194)
Uh oh!
There was an error while loading.Please reload this page.
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/