Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
iritkatriel merged 9 commits intopython:mainfromgaogaotiantian:pdb-interact-test
Dec 7, 2023

Conversation

@gaogaotiantian
Copy link
Member

@gaogaotiantiangaogaotiantian commentedOct 23, 2023
edited
Loading

With the long due#102896, we can finally add tests forinteract command.

However, the currentinteract command usescode.interact directly which makes it super difficult to test, becausecode.interact writes tosys.stderr directly (withsys.stderr.write)! We need to overload thewrite method 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

  1. This PR will be not backported, so it's a new thing.
  2. The current status (plus the interactive issue ingh-102895 Add an option local_exit in code.interact to block exit() from terminating the whole process #102896 before the fix) made it almost impossible to write tests forinteract command, so I don't think we'll break anything.

This PR adds the class for interact commmand and some basic tests forinteract; 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 exitinteract command is also added to the docs.


📚 Documentation preview 📚:https://cpython-previews--111194.org.readthedocs.build/

@gaogaotiantiangaogaotiantian changed the titlegh-102980: Add tests and some extra notes for pdb's interact commandgh-102980: Redirect pdbinteract command, add tests and improve docsOct 23, 2023
@gaogaotiantian
Copy link
MemberAuthor

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.
Copy link
Member

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?

Copy link
MemberAuthor

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.

@iritkatrieliritkatriel added the stdlibStandard Library Python modules in the Lib/ directory labelDec 6, 2023
@iritkatrieliritkatrielenabled auto-merge (squash)December 7, 2023 11:03
@iritkatrieliritkatriel merged commit3d712a9 intopython:mainDec 7, 2023
@gaogaotiantian
Copy link
MemberAuthor

Thanks for the review!

@gaogaotiantiangaogaotiantian deleted the pdb-interact-test branchDecember 7, 2023 19:13
aisk pushed a commit to aisk/cpython that referenced this pull requestFeb 11, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this pull requestSep 2, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@iritkatrieliritkatrieliritkatriel approved these changes

@brandtbucherbrandtbucherAwaiting requested review from brandtbucher

Assignees

No one assigned

Labels

stdlibStandard Library Python modules in the Lib/ directorytestsTests in the Lib/test dir

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@gaogaotiantian@iritkatriel

[8]ページ先頭

©2009-2025 Movatter.jp