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 rhettinger, serhiy.storchaka, taleinat, terry.reedy
Date 2019-08-16.15:02:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1565967739.67.0.659637242288.issue37824@roundup.psfhosted.org>
In-reply-to
Content
The triple (or double, see below) printing seems like a pure bug to be fixed.  A fix could be a separate PR to be merged 'immediately'.

But there is a complication with insertion location.  My bug claim was based on a one line statement, where 'before' looks wrong and 'after', as in REPL, right.

>>> <IDLE>
Warning (from warnings module):  # Printed 3 times, 2 deleted.
  File "<pyshell#0>", line 1
    0 is 0
SyntaxWarning: "is" with a literal. Did you mean "=="?
0 is 0
True

>>> 0 is 0  # REPL
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
True

But now consider a more realistic compound statement.

>>> if 0 is 0:  # REPL
...   print('true')
...
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
true

With IDLE, a warning is printed *before* the user enters a blank line to signal end of statement.

>>> 
Warning (from warnings module):  # Only printed TWICE!.
  File "<pyshell#2>", line 1
    if 0 is 0:
SyntaxWarning: "is" with a literal. Did you mean "=="?
if 0 is 0:
	print('true')
	|< cursor location

A user could edit the condition, add more to the suite, or hit return. In the latter 2 cases, the warnings are repeated.  In this case, the insertion seems like the best that can be done.

Perhaps the msg349845 comment about run.show_warnings collecting warnings for possible delayed display applies to pyshell.show_warnings.  Or the warning could be put in a popup, though I do not especially like the idea of that.  Or it could be logged to a separate Warnings window, and a red "Warning logged' flashed on the status bar.

I suspect that this case is why a fake prompt was previously tacked on to the end of the warning, though I also suspect these complications are why shell input warnings were relegated to a possibly non-existent console (where the fake prompt is nonsense).

Behavior is the same with '\e' and DeprecationWarning.

This example further convinces me that multiline shell input should be isolated from both prompts and intermixed outputs.  I plan to open that issue later today.
History
Date User Action Args
2019-08-16 15:02:19terry.reedysetrecipients: + terry.reedy, rhettinger, taleinat, serhiy.storchaka
2019-08-16 15:02:19terry.reedysetmessageid: <1565967739.67.0.659637242288.issue37824@roundup.psfhosted.org>
2019-08-16 15:02:19terry.reedylinkissue37824 messages
2019-08-16 15:02:19terry.reedycreate