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 Phaqui, gvanrossum, terry.reedy
Date 2019-11-08.22:55:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1573253709.81.0.326562808163.issue38673@roundup.psfhosted.org>
In-reply-to
Content
Entering 'pass' or a completely blank line results in a new primary prompt, at least on Windows. The Windows REPL otherwise prints ... even for effectively blank lines.  IDLE usually prints a new prompt for effectively blank lines.

>>> 
>>> #a
>>> # a
>>>  #a
>>>

I agree that these look better.  This behavior comes from code.InteractiveInterpreter and ultimately codeop.

def _maybe_compile(compiler, source, filename, symbol):
    # Check for source consisting of only blank lines and comments
    for line in source.split("\n"):
        line = line.strip()
        if line and line[0] != '#':
            break               # Leave it alone
    else:
        if symbol != "eval":
            source = "pass"     # Replace it with a 'pass' statement

As noted above, 'pass\n' is treated the same as '\n'

The first line above originally had a space, but IDLE appears to strip trailing whitespace also, even outside of comments.  (For an ending '\ ', this prevents SyntaxError, but maybe this is a bad lesson for beginners.)  However, I did find a case with an unnecessary continuation line.

>>>  # a
 
>>> 

This puzzles me, as it should be treated exactly the same as without the space after '#'.  ast.dump(ast.parse(' # a\n', '', 'single')) gives the same result, 'Module(body=[], type_ignores=[])', as without.
History
Date User Action Args
2019-11-08 22:55:09terry.reedysetrecipients: + terry.reedy, gvanrossum, Phaqui
2019-11-08 22:55:09terry.reedysetmessageid: <1573253709.81.0.326562808163.issue38673@roundup.psfhosted.org>
2019-11-08 22:55:09terry.reedylinkissue38673 messages
2019-11-08 22:55:09terry.reedycreate