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 2010年08月15日 22:52 by cben, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (5) | |||
|---|---|---|---|
| msg114019 - (view) | Author: Cherniavsky Beni (cben) * | Date: 2010年08月15日 22:52 | |
[Spinoff of http://bugs.python.org/issue3559] If you manage to type several simple statements into the prompt (by copy-pasting them, using Ctrl+J, or creative deletion), IDLE runs the first one and silently ignores the rest: >>> x = 1 x = 2 >>> x 1 Moreover, it doesn't even parse the additional lines: >>> x = 3 $@syntax error?! >>> x 3 If the first statement is a compound statement, IDLE refuses with a SyntaxError at the begging of the second statement: >>> def f(): return 42 f() SyntaxError: invalid syntax I believe in both cases the right least-surprise behavior is to run all statements. If not, a clear error explaining that IDLE doesn't support multiple statements must be printed. But I can't see a reason to choose this over making it Just Work. [Implementation: might or might not be related to http://bugs.python.org/issue7741] |
|||
| msg114438 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2010年08月20日 18:15 | |
In interactive mode, multiline statements are terminated with a blank line. Your examples lacks that, so the 3rd line is part of the def and lacking the proper indent, is indeed a syntax error. You get the same with the standard command-line interpreter. >>> def f(): ... return 42 ... f() File "<stdin>", line 3 f() ^ SyntaxError: invalid syntax That said, adding a blank line still gives a syntax error in IDLE, instead of ignoring the extra statement, while the interpreter prints 42. IDLE requires an explicit blank line from the keyboard to terminate compound statements; pasted blank lines do not count #3559 (which I now see you commented on - I should have been notified but was not). I suspect you are correct about the dependency on code.InteractiveConsole(), but I have not looked at the IDLE code either. In the meanwhile, either paste multiple statements in the the real interpreter or into an IDLE window and use F5 run. |
|||
| msg114478 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2010年08月21日 04:10 | |
It seems to me that this bug should be closed as a duplicate of the original bug (#3559). It's the same bug, only the proposed solution is different, unless I'm missing something. |
|||
| msg114546 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2010年08月21日 19:10 | |
I agree: Implementation note: PyShell.py hass the following line: from code import InteractiveInterpreter That is the base class for InteractiveConsole, the subject of #7741. PyShell makes it own extension class ModifiedInterpreter(InteractiveInterpreter): |
|||
| msg114555 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2010年08月21日 19:36 | |
To be clearer, this issue is an elaboration of the #3559 report that <statement>\n<statement> 'does not work' in that it points out that <simple statement>\n<simplestatement> silently ignores the second while <compoundstatement>\n<simplestatement> is reported as a syntax error. I agree that this elaboration should have been included there and I am adding a message there. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:05 | admin | set | github: 53827 |
| 2016年07月21日 01:29:11 | THRlWiTi | set | nosy:
+ THRlWiTi |
| 2010年08月21日 19:36:17 | terry.reedy | set | messages: + msg114555 |
| 2010年08月21日 19:10:01 | terry.reedy | set | status: open -> closed resolution: duplicate superseder: IDLE: Pasted newline doesn't trigger execution when typed newline would messages: + msg114546 |
| 2010年08月21日 04:10:36 | r.david.murray | set | nosy:
+ r.david.murray messages: + msg114478 |
| 2010年08月20日 18:15:30 | terry.reedy | set | versions:
- Python 2.7 nosy: + terry.reedy messages: + msg114438 type: enhancement |
| 2010年08月16日 17:50:56 | eric.araujo | set | nosy:
+ kbk, eric.araujo |
| 2010年08月15日 22:52:07 | cben | create | |