This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2011年11月29日 14:56 by ngie, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| python-cmd-reset-lastcmd-on-EOF.patch | ngie, 2011年11月29日 14:56 | review | ||
| python-issue13500-test.patch | ngie, 2012年01月17日 08:07 | review | ||
| Messages (13) | |||
|---|---|---|---|
| msg148575 - (view) | Author: Enji Cooper (ngie) * | Date: 2011年11月29日 14:56 | |
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..). |
|||
| msg148597 - (view) | Author: Jesús Cea Avión (jcea) * (Python committer) | Date: 2011年11月29日 19:51 | |
Could you provide an step-by-step procedure to try this?. |
|||
| msg148600 - (view) | Author: Enji Cooper (ngie) * | Date: 2011年11月29日 20:04 | |
Sure -- the repro steps are pretty easy:
1. Startup an interactive python shell.
2. Enter in the following code:
{{{
import cmd
class Foo(cmd.Cmd):
def do_bar(self, arg):
"""bar"""
Foo().cmdloop()
}}}
3. You will be greeted with the standard `(Cmd)' prompt.
4. Press enter. Nothing will be printed out (it will continue on to the next line).
5. Enter in Control-D, you will be greeted with `Unknown syntax: EOF' error message from cmd.Cmd.default(..).
6. Press enter multiple times.
Expected output:
- Since a do_EOF handler isn't installed in 5., I expect to see the `Unknown syntax: EOF' error print out on the console. I don't want to delve into whether or not this should or shouldn't be printed out in this ticket.
- Every time I press <enter> I should be greeted with the prompt, and not the `Unknown syntax: EOF` error.
Actual output:
- I see `Unknown syntax: EOF' error, and every time I press <enter> it displays the error beforementioned error.
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
}}}
|
|||
| msg148932 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2011年12月06日 19:47 | |
New changeset 5910c385fab6 by Jesus Cea in branch '2.7': Close #13500: Hitting EOF gets cmd.py into a infinite EOF on return loop http://hg.python.org/cpython/rev/5910c385fab6 New changeset b6b4d74b8d42 by Jesus Cea in branch '3.2': Close #13500: Hitting EOF gets cmd.py into a infinite EOF on return loop http://hg.python.org/cpython/rev/b6b4d74b8d42 New changeset 70ba352f9586 by Jesus Cea in branch 'default': MERGE: Close #13500: Hitting EOF gets cmd.py into a infinite EOF on return loop http://hg.python.org/cpython/rev/70ba352f9586 |
|||
| msg148933 - (view) | Author: Jesús Cea Avión (jcea) * (Python committer) | Date: 2011年12月06日 19:49 | |
Garrett, please verify the fix. |
|||
| msg148971 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2011年12月07日 16:09 | |
I believe the commit would have needed a regression test. |
|||
| msg148972 - (view) | Author: Enji Cooper (ngie) * | Date: 2011年12月07日 16:11 | |
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. |
|||
| msg148973 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2011年12月07日 16:16 | |
> 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. |
|||
| msg148976 - (view) | Author: Enji Cooper (ngie) * | Date: 2011年12月07日 16:37 | |
Ok. I'll see if I can provide a unittest for this by the 12th. |
|||
| msg151431 - (view) | Author: Enji Cooper (ngie) * | Date: 2012年01月17日 08:07 | |
Here's a unittest patch for the py3k branch.
{{{
1 items passed all tests:
32 tests in test.test_cmd.samplecmdclass
32 tests in 19 items.
32 passed and 0 failed.
Test passed.
doctest (test.test_cmd) ... 32 tests with zero failures
test_file_with_missing_final_nl (__main__.TestAlternateInput) ... ok
test_input_reset_at_EOF (__main__.TestAlternateInput) ... ok
----------------------------------------------------------------------
Ran 2 tests in 0.000s
OK
}}}
|
|||
| msg153666 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年02月19日 02:52 | |
New changeset 5af5e6b2c053 by Jesus Cea in branch 'default': Test for issue #13500 http://hg.python.org/cpython/rev/5af5e6b2c053 |
|||
| msg153667 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年02月19日 02:55 | |
New changeset 0d442e166c8f by Jesus Cea in branch '2.7': Test for issue #13500 http://hg.python.org/cpython/rev/0d442e166c8f New changeset 3a40af30449e by Jesus Cea in branch '3.2': Test for issue #13500 http://hg.python.org/cpython/rev/3a40af30449e New changeset ad204ed6ac51 by Jesus Cea in branch 'default': MERGE: Test for issue #13500 http://hg.python.org/cpython/rev/ad204ed6ac51 |
|||
| msg153668 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年02月19日 03:21 | |
New changeset 2909e60e7e13 by Jesus Cea in branch '2.7': Fix Test for issue #13500 http://hg.python.org/cpython/rev/2909e60e7e13 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:24 | admin | set | github: 57709 |
| 2012年02月19日 03:21:28 | python-dev | set | messages: + msg153668 |
| 2012年02月19日 02:55:10 | python-dev | set | messages: + msg153667 |
| 2012年02月19日 02:52:32 | python-dev | set | messages: + msg153666 |
| 2012年01月17日 08:07:04 | ngie | set | files:
+ python-issue13500-test.patch messages: + msg151431 |
| 2011年12月07日 16:37:25 | ngie | set | messages: + msg148976 |
| 2011年12月07日 16:16:45 | eric.araujo | set | messages: + msg148973 |
| 2011年12月07日 16:11:47 | ngie | set | messages: + msg148972 |
| 2011年12月07日 16:09:12 | eric.araujo | set | messages: + msg148971 |
| 2011年12月06日 19:49:34 | jcea | set | messages: + msg148933 |
| 2011年12月06日 19:48:58 | jcea | set | assignee: jcea |
| 2011年12月06日 19:47:47 | python-dev | set | status: open -> closed nosy: + python-dev messages: + msg148932 resolution: fixed stage: resolved |
| 2011年12月03日 14:55:23 | eric.araujo | set | nosy:
+ vstinner, eric.araujo versions: + Python 2.7, Python 3.2 |
| 2011年11月29日 20:04:42 | ngie | set | messages: + msg148600 |
| 2011年11月29日 19:51:39 | jcea | set | nosy:
+ jcea messages: + msg148597 versions: + Python 3.3, - Python 3.4 |
| 2011年11月29日 14:56:40 | ngie | create | |