[issue37824] IDLE: Handle Shell input warnings properly.

2020-05-29 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

The new items can be new issues, with 6 maybe the highest priority.  Currently
:1: DeprecationWarning: invalid escape sequence \e
becomes
Warning (from warnings module):
  File "", line 1
'\e'
DeprecationWarning: invalid escape sequence \e

For both Shell and Editor input, the Warning Line is not really needed.  For 
Shell, the fake filename is not needed, nor is the line # and line if somehow 
otherwise marked.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37824] IDLE: Handle Shell input warnings properly.

2020-05-29 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

To review: Serhiy reported 3 'IDLE' bugs: tripled DeprecationWarning (now 
joined by SyntaxWarning), printing to console (if available) instead of Shell, 
and an exit exception.

1. Codeop generates the tripicates; #40807 will fix that.
2. PR-15311 prints warnings to Shell, but I held off  pending some fix.  3. The 
exception (a duplicate report) was fixed on #35623.
4. PR-15500 stopped turning a SyntaxWarning into a SyntaxError.

Additional issues, semi-independent.
5. REPL prints warning after code, IDLE before
6. REPL prints 1 line, IDLE 4, but this is related to Shell warnings going to 
the console.  IDLE should use 1 and highlight.
7. Should IDLE extend scope of deduplication?  Yes with 4 lines, maybe not with 
1 line.
8. REPL partially deduplicates within compound statement; see #40807.

--
versions:  -Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37824] IDLE: Handle Shell input warnings properly.

2020-05-28 Thread Cheryl Sabella


Cheryl Sabella  added the comment:

Thanks, Terry.  I created issue40807 for the codeop warnings.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37824] IDLE: Handle Shell input warnings properly.

2020-05-27 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
versions: +Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37824] IDLE: Handle Shell input warnings properly.

2020-05-27 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

codeop._maybe_compile wraps each compile in try ... except SyntaxError.  It can 
later reraise just once.  I think it a bug that it is not similarly careful 
about SyntaxWarning and DeprecationWarning to only emit a particular warning 
just once.

Cheryl, would you like to open a new issue and submit a patch?

--
versions:  -Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37824] IDLE: Handle Shell input warnings properly.

2020-05-26 Thread Tal Einat


Change by Tal Einat :


--
versions: +Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37824] IDLE: Handle Shell input warnings properly.

2020-05-25 Thread Cheryl Sabella


Cheryl Sabella  added the comment:

I added a commit to the PR to show warnings once.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37824] IDLE: Handle Shell input warnings properly.

2020-05-25 Thread Cheryl Sabella


Cheryl Sabella  added the comment:

Terry,

I put this into debug and found the reason it's printing the warning three 
times.  In `codeop.py`, it's running `_maybe_compile` and there are three try 
statements:

```
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

err = err1 = err2 = None
code = code1 = code2 = None

try:
code = compiler(source, filename, symbol)
except SyntaxError:
pass

try:
code1 = compiler(source + "\n", filename, symbol)
except SyntaxError as e:
err1 = e

try:
code2 = compiler(source + "\n\n", filename, symbol)
except SyntaxError as e:
err2 = e

try:
if code:
return code
if not code1 and repr(err1) == repr(err2):
raise err1
finally:
err1 = err2 = None
```

It also has this in the module docstring:
```
Compile three times: as is, with \n, and with \n\n appended.  If it
compiles as is, it's complete.  If it compiles with one \n appended,
we expect more.  If it doesn't compile either way, we compare the
error we get when compiling with \n or \n\n appended.  If the errors
are the same, the code is broken.  But if the errors are different, we
expect more.  Not intuitive; not even guaranteed to hold in future
releases; but this matches the compiler's behavior from Python 1.4
through 2.2, at least.
```

--
nosy: +cheryl.sabella

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37824] IDLE: Handle Shell input warnings properly.

2019-08-26 Thread miss-islington


miss-islington  added the comment:


New changeset 1b15914ebb46e549ff0965c789ef03b4bac2a890 by Miss Islington (bot) 
in branch '3.7':
bpo-37824: Properly handle user input warnings in IDLE shell. (GH-15500)
https://github.com/python/cpython/commit/1b15914ebb46e549ff0965c789ef03b4bac2a890


--
nosy: +miss-islington

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37824] IDLE: Handle Shell input warnings properly.

2019-08-26 Thread Terry J. Reedy


Terry J. Reedy  added the comment:


New changeset 077887059a5b3d38161dfd74b160c701445a1ef0 by Terry Jan Reedy (Miss 
Islington (bot)) in branch '3.8':
bpo-37824: Properly handle user input warnings in IDLE shell. (GH-15500)
https://github.com/python/cpython/commit/077887059a5b3d38161dfd74b160c701445a1ef0


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37824] IDLE: Handle Shell input warnings properly.

2019-08-26 Thread miss-islington


Change by miss-islington :


--
pull_requests: +15190
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/15504

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37824] IDLE: Handle Shell input warnings properly.

2019-08-26 Thread miss-islington


Change by miss-islington :


--
pull_requests: +15191
pull_request: https://github.com/python/cpython/pull/15505

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37824] IDLE: Handle Shell input warnings properly.

2019-08-26 Thread Terry J. Reedy


Terry J. Reedy  added the comment:


New changeset 1039f39c9c6edb4c185856c19316d3a4eb561c38 by Terry Jan Reedy in 
branch 'master':
bpo-37824: Properly handle user input warnings in IDLE shell. (GH-15500)
https://github.com/python/cpython/commit/1039f39c9c6edb4c185856c19316d3a4eb561c38


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37824] IDLE: Handle Shell input warnings properly.

2019-08-25 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I pulled the part of PR 15311 that works, stop turning Shell SyntaxWarnings 
into SyntaxErrors, into PR-15500, to get it into b4.  I will update the former 
after merging the latter.

--
stage: patch review -> 

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37824] IDLE: Handle Shell input warnings properly.

2019-08-25 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
pull_requests: +15189
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/15500

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37824] IDLE: Handle Shell input warnings properly.

2019-08-16 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

My first post described master at the time, when SyntaxWarnings were converted 
to SyntexErrors and shell input warnings, in particular, Deprecation warnings 
were sent to the console or nowhere.  My third post describes the situation 
with the PR, where SyntaxWarnings are left as warnings and shell input warnings 
go to shell.  An improvement, but still buggy.  I just reconfirmed after 
updating, compiling Python, and checking out my 'warn' branch.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37824] IDLE: Handle Shell input warnings properly.

2019-08-16 Thread Tal Einat


Tal Einat  added the comment:

I see none of this on latest master (0567786d26348aa7eaf0ab1b5d038fdabe409d92) 
on Windows 10.  Can you specify on what OS and Python branch/version this 
happens?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37824] IDLE: Handle Shell input warnings properly.

2019-08-16 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

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.

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

>>> 0 is 0  # REPL
: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')
...
: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 "", 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.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37824] IDLE: Handle Shell input warnings properly.

2019-08-16 Thread Tal Einat


Tal Einat  added the comment:

Il take a look at this. I've very recently gone through the relevant parts of 
the code and I should be able to figure it it efficiently.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37824] IDLE: Handle Shell input warnings properly.

2019-08-15 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I am combining the trivial 'leave Shell input SyntaxWarnings alone (instead of 
making them SyntaxErrors)' part of #34857 with this issue, 'print Shell input 
(and the very rare internal IDLE Warnings occurring after Shell exists) in 
Shell, and changing the title accordingly.

The PR is a WIP with at least two bugs. Help wanted.
1. the triple output.  (Before the patch, when I started IDLE from command 
prompt, I only saw one.
2. Warnings are inserted before the text generating the warning.  I interpret 
this as intercepted \n causing compilation and printing of the warning before 
the \n is inserted at the end of the line and the iomark moved to the beginning 
of the next.  I don't know what moves the iomark.

--
stage: patch review -> 

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37824] IDLE: Handle Shell input warnings properly.

2019-08-15 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
keywords: +patch
pull_requests: +15030
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/15311

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37824] IDLE: Handle Shell input warnings properly.

2019-08-15 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
nosy: +rhettinger, taleinat
title: IDLE: DeprecationWarning not handled properly -> IDLE: Handle Shell 
input warnings properly.

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com