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.

Author terry.reedy
Recipients cben, eric.araujo, gpolo, terry.reedy
Date 2010-08-21.20:46:39
SpamBayes Score 4.44089e-16
Marked as misclassified No
Message-id <1282423602.5.0.0506641476336.issue3559@psf.upfronthosting.co.za>
In-reply-to
Content
I switched to patch review because I am not sure unit test is possible.

I did not advocate a change to immediate execution in my original post. I noted that pasting multiple statements does not work and that if it cannot be made to work, the limitation should be documented. I am fine with pasting working the same as when one copies a previous statement to the current input prompt with <cursor on line>+Enter.

Issue #9618 elaborated "<statement>\n<statement> does not work" by pointing out that <simple statement>\n<simplestatement> silently ignores the second while <compoundstatement>\n<simplestatement> is reported as a syntax error. I pointed out that if <compoundstatement> does not end in \n, it really is a syntax errror for interactive mode, but even with \n\n, it still is reported as such when it is not.

So a possible revised minimal request is that an initial compound statement be executed and the rest ignored. However ....

I have discover that the elaboration is not exactly true either. msg114019 says "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:" However, when I edit 'for x in []:' to 'x = 3' *after* adding '    y = 7' I get with 3.1:
>>> x
2
>>> y
4
>>> x = 3
	y = 7
	
>>> x
3
>>> 7
7
Somehow, both statements are executed because of the indent! This might be considered a bug as the indent should be a syntax error. Without it, the second line is ignored, as reported.

The significant difference between the (Windows) interactive interpreter and IDLE is that the II is *line* oriented* while IDLE is *statement* oriented. With II, entry (and history) is by single lines. A line entered cannot be edited and history (up/down arrow) copies a single previous line. Multiline compound statements require *manual* indentation. Rerunning (and editing) a multiline compound statement requires rerunning (and editing) each line one at a time. IDLE, allows multiline editing before the double Enter (hence the shenanigans above, impossible with II), does auto indents, and retrieves and allows editing of entire multiline statements with <cursor>+Enter.

Since the IDLE Shell operates differently from the II, it cannot and should not imitate II paste behavior. It seems to treat pasted code more-or-less the same as edited code from the keyboard, which it expects to be a statement, single-line multi-statment, or compound statement. If there is a problem, I think perhaps it is in how it handles abusively edited multiline statements. Perhaps it should always raise SyntaxError instead of silently ignoring part of the entry.
History
Date User Action Args
2010-08-21 20:46:42terry.reedysetrecipients: + terry.reedy, cben, gpolo, eric.araujo
2010-08-21 20:46:42terry.reedysetmessageid: <1282423602.5.0.0506641476336.issue3559@psf.upfronthosting.co.za>
2010-08-21 20:46:41terry.reedylinkissue3559 messages
2010-08-21 20:46:39terry.reedycreate