Terry J. Reedy <[email protected]> added the comment:
The SyntaxError is not relevant. Interactive CPython:
>>> d=[]
>>> d=()
>>> d={}
>>>
Erroneous extra lines in IDLE 3.6+ Shell but not editor:
>>> d = []
>>> d=()
>>> d={}
>>> d=[i for i in [1]]
>>>
The 'blank' lines are indents produced by IDLE's smart indent mechanism, which
is trigger by keying '\n', *before* the code is tentatively compiled.
While the extra lines are an error for the examples above, they are arguably
correct for your example, where there is no closing '}'. The indenter treats
it the same as if there were a closing quote, as in the following, which *is*
the same in shell and editor, and correct.
d = {1: 'one}'
# Indent lines up next dict item with the one above.
Even though your example is no a bug, it lead me to discover a regression in
current 3.6+. In the past year, there have been a couple of patches that
touched the autoindent code.
----------
stage: -> test needed
title: IDLE inserts extra blank line in prompt after SyntaxError -> IDLE:
erroneous 'smart' indents in shell
versions: +Python 3.7, Python 3.8
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue34055>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com