-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-120606: Allow EOF to exit pdb commands definition #120607
Conversation
@@ -860,6 +860,9 @@ def handle_command_def(self, line): | |||
return False # continue to handle other cmd def in the cmd list | |||
elif cmd == 'end': | |||
return True # end of cmd list | |||
elif cmd == 'EOF': | |||
print('') | |||
return True # end of cmd list |
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.
(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?
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.
(1) Because EOF
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 do Ctrl+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 in commands
command saying that inputting an EOF
character will also exit the commands
command.
(3) The test involving EOF is not easy to test, especially if you still want to input something after. Currently pdb
does not really test it. One way around this is to use "EOF"
as an explicit command to simulate the EOF
user inputs. That would make the test super trivial to write. We are relying on cmd.Cmd
to convert Ctrl+D
(Ctrl+Z
on Windows I believe) to the correct EOF
command. Does that sound reasonable to you?
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.
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.
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.
Okay I added a basic test in an existing test case. Notice that <BLANKLINE>
appears in the output because EOF\n
creates a new line but Ctrl-D
will not have that new line. So EOF\n
results in an extra new line compared to Ctrl-D
. We don't want the user to stay on the same line after Ctrl-D
so we need to output a new line in that command.
Thanks for the review! |
Uh oh!
There was an error while loading. Please reload this page.