-
-
Notifications
You must be signed in to change notification settings - Fork 30k
-
-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Hitting EOF gets cmd.py into a infinite EOF on return loop #57709
Comments
Pressing <enter> produces no output with cmd.py whenever ^D has been entered in; after I enter in ^D it gets into an infinite loop spewing out messages via cmd.Cmd.default() about EOF because self.lastcmd isn't being reset properly. The attached patch fixes that usability nit to be more intuitive (I debated about changing 'EOF' to 0x10, but that's probably less intuitive..). |
Could you provide an step-by-step procedure to try this?. |
Sure -- the repro steps are pretty easy:
{{{ Foo().cmdloop()
Expected output:
Actual output:
Example: {{{
>>> import cmd
>>> class Foo(cmd.Cmd):
... def do_bar(self, arg):
... """bar"""
...
>>> Foo().cmdloop()
(Cmd)
(Cmd)
bar help
(Cmd) help bar
bar
(Cmd) ^D*** Unknown syntax: EOF
(Cmd)
*** Unknown syntax: EOF
(Cmd)
*** Unknown syntax: EOF
}}} |
New changeset 5910c385fab6 by Jesus Cea in branch '2.7': New changeset b6b4d74b8d42 by Jesus Cea in branch '3.2': New changeset 70ba352f9586 by Jesus Cea in branch 'default': |
Garrett, please verify the fix. |
I believe the commit would have needed a regression test. |
I'll verify the fix in another day or two. FWIW unless python is willing to import pexpect, or provide an equivalent, I'm not sure how items like this which require interactive input can be run via the python project testing framework. |
Replace sys.stdin with a custom object (a stub) and you can control input (see the Inputs class used in Lib/packaging/tests/test_create.py or Lib/packaging/tests/test_command_register.py). The readline module would not be used however, so that can’t be tested. |
Ok. I'll see if I can provide a unittest for this by the 12th. |
Here's a unittest patch for the py3k branch. {{{ ---------------------------------------------------------------------- OK |
New changeset 5af5e6b2c053 by Jesus Cea in branch 'default': |
New changeset 0d442e166c8f by Jesus Cea in branch '2.7': New changeset 3a40af30449e by Jesus Cea in branch '3.2': New changeset ad204ed6ac51 by Jesus Cea in branch 'default': |
New changeset 2909e60e7e13 by Jesus Cea in branch '2.7': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: