◐ Shell
clean mode source ↗

Message 386622 - Python tracker

#43151 asked about 'is <literal>' syntax warnings in REPL.  Discussion noted that IDLE Shell does note print it for "x is 'a'" (known here) and that for "if x is 'a': print('executed')" there is a syntax error and no execution.  The conversion to SyntaxError was supposedly fixed by PR-15500, but it appears that the patch for #40807 introduced it into codeop._maybe_compile.

msg386621 has summary and discussion.  I need to add debug prints or breakpoints into _maybe_compile to understand it better, and maybe improve it.

Before printing syntax warnings in Shell, I want to stop expanding them from 1 to 4 lines.  We could just not import the replacement from run.py, but I think the default format could be improved even with 1 or 2 lines.