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 Dennis Sweeney, garylitvin, rhettinger, steven.daprano, terry.reedy
Date 2021-02-08.08:20:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1612772406.92.0.829795440312.issue43151@roundup.psfhosted.org>
In-reply-to
Content
I verified that there are two discrepancies in IDLE versus the standard REPL on Windows with 3.10.0a5.  The latter first (which does not converted warnings to errors).

Python 3.10.0a4+ (heads/master:0332e569c1, Feb  1 2021, 09:19:58) [MSC v.1900 64 bit (AMD64)] on win32

>>> x = 'a'
>>> x is 'a'
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
True
>>> if x is 'a': print('executed')
...
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
executed

versus, with IDLE, 

>>> x = 'a'
>>> x is 'a'  # No warning, also executed.
True
>>> if x is 'a': pass  # Error instead of warning, hence not executed.
SyntaxError: "is" with a literal. Did you mean "=="?

There is no "IDLE parser" for interactive input.  IDLE's Shell uses a subclass of code.InteractiveInterpreter, which calls codeop.CommandCompiler.  The latter calls codeop._maybe_compile, which calls compile() 3 times for the source as is, with '\n' appended, and with '\n\n' appended.  #40807 fixed the issue of getting 3 warnings instead of 1.

For the comparison "x is 'a'", all three compiles emit SyntaxWarning before _maybe_compile returns a code object.  The last two warnings are suppressed.  IDLE not printing Shell input warnings it is the subject of #37824.

Compiling the if statement without a final \n raises
SyntaxError: unexpected EOF while parsing
Adding '\n' results in the warning (converted to error in _maybe_compile) and a code object.


I think there is a bug in the revised _maybe_compile but I need to add prints or breakpoints to properly understand it.  And have someone locate and explain the REPL C code. If I decide _maybe_compile should be patched, I will open a new issue.

---
PS Gary, when replying by email, please delete what you are responding to, except possibly for a line or two.  When posted on the web page below what you respond to, the full quote is redundant noise.

Also, questions like 'How come?' should better be asked on python-list (or other question-asking forums).  Discussion there can lead to specific issues here.
History
Date User Action Args
2021-02-08 08:20:06terry.reedysetrecipients: + terry.reedy, rhettinger, steven.daprano, Dennis Sweeney, garylitvin
2021-02-08 08:20:06terry.reedysetmessageid: <1612772406.92.0.829795440312.issue43151@roundup.psfhosted.org>
2021-02-08 08:20:06terry.reedylinkissue43151 messages
2021-02-08 08:20:05terry.reedycreate