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-120606: Allow EOF to exit pdb commands definition#120607

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

Conversation

@gaogaotiantian
Copy link
Member

@gaogaotiantiangaogaotiantian commentedJun 16, 2024
edited by bedevere-appbot
Loading

returnTrue# end of cmd list
elifcmd=='EOF':
print('')
returnTrue# end of cmd list
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

(1) why do we need two instructions to do the same thing?
(2) why add a feature and not document it?
(3) where is the test?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

(1) BecauseEOF is a special command triggered when user "inputs" EOF (Ctrl+D on Linux). It's not something we added, it's something we need to deal with. Users will doCtrl+D as a habit from all the other similar usages and expect a reasonable result. Currently the behavior is pretty bad.

(Pdb) commands 1(com) (com) (com) (com) (com) (com)

(2) Like I said, this is a reaction to a very natural user input. I think that's a very expected behavior. However, we can add something incommands command saying that inputting anEOF character will also exit thecommands command.

(3) The test involving EOF is not easy to test, especially if you still want to input something after. Currentlypdb does not really test it. One way around this is to use"EOF" as an explicit command to simulate theEOF user inputs. That would make the test super trivial to write. We are relying oncmd.Cmd to convertCtrl+D (Ctrl+Z on Windows I believe) to the correctEOF command. Does that sound reasonable to you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I see. That context can be encoded in a test. Add the trivial test for 'EOF' and put a comment there that this is what cmd produces for Ctrl+D.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Okay I added a basic test in an existing test case. Notice that<BLANKLINE> appears in the output becauseEOF\n creates a new line butCtrl-D will not have that new line. SoEOF\n results in an extra new line compared toCtrl-D. We don't want the user to stay on the same line afterCtrl-D so we need to output a new line in that command.

@gaogaotiantian
Copy link
MemberAuthor

Thanks for the review!

@gaogaotiantiangaogaotiantian merged commit4bbb027 intopython:mainJun 19, 2024
@gaogaotiantiangaogaotiantian deleted the pdb-commands-def-eof branchJune 19, 2024 22:50
mrahtz pushed a commit to mrahtz/cpython that referenced this pull requestJun 30, 2024
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull requestJul 11, 2024
estyxx pushed a commit to estyxx/cpython that referenced this pull requestJul 17, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@iritkatrieliritkatrieliritkatriel approved these changes

Assignees

No one assigned

Labels

None yet

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