[issue45560] sys.last_* not set for SyntaxErrors with IDLE

2022-01-26 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

If this is not fixed, perhaps it should be documented along with other IDLE 
differences in Running User code.

--

___
Python tracker 

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



[issue45560] sys.last_* not set for SyntaxErrors with IDLE

2021-10-21 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

#43476 is clearly an enhancement request.  It proposes to stash info in the GUI 
process in a way that lets it be into from the other process by non-standard 
means.

This is closer to a bugfix request in that successive lines have a different 
response in REPL and Shell.  Having sys attributes different in the two 
environments is not a bug in itself: for instance, sys.stdxxx *must* be 
different in the two environments because the standard streams *are* different. 
 Having sys.last_type, for instance, being either None or wrong (the last 
non-syntax error) instead of SyntaxError is something different.  I fix here 
will be harder, but I like it better.

--

___
Python tracker 

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



[issue45560] sys.last_* not set for SyntaxErrors with IDLE

2021-10-21 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

The method to run just code in userspace, without involving the debugger or 
history list, is runcommand.  It needs a code string.  The hard part is the 
code needed to recreate the exception instance in the user space.  It will be 
different for SyntaxError versus the other error possible when compiling.  The 
SE details tuple has a mix of strs and ints.  I believe I know in principle how 
to do it.

--

___
Python tracker 

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



[issue45560] sys.last_* not set for SyntaxErrors with IDLE

2021-10-21 Thread Andre Roberge


Andre Roberge  added the comment:

If this can be implemented, then I believe that 
https://bugs.python.org/issue43476 could be closed as well.

--

___
Python tracker 

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



[issue45560] sys.last_* not set for SyntaxErrors with IDLE

2021-10-21 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

This is most likely an oversight.  It affects both normal and -n mode.  The 
three sys attributes can be written.  Given the error instance e caught in the 
IDLE process, we need to execute, *in the user namespace*,
  sys.last_type, sys.last_value, sys.traceback = type(e), e, None

The syntax error handle should call run_source (or maybe run_code).  I will 
make a PR if it seem to work.

--
stage:  -> test needed
type:  -> behavior
versions:  -Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue45560] sys.last_* not set for SyntaxErrors with IDLE

2021-10-21 Thread Andre Roberge


New submission from Andre Roberge :

As stated in the documentation, sys.last_type, sys.last_value and 
sys.last_traceback ... are set when an exception is not handled and the 
interpreter prints an error message and a stack traceback.

This is true whether the exception is a SyntaxError or some runtime error when 
a standard Python interpreter is used.

However, when the IDLE shell is used and a SyntaxError occurs, these are not 
set.  If it is not possible to change this behaviour in IDLE, perhaps the 
documentation of the sys module should be amended to include this information.

--
assignee: terry.reedy
components: IDLE
messages: 404669
nosy: aroberge, terry.reedy
priority: normal
severity: normal
status: open
title: sys.last_* not set for SyntaxErrors with IDLE
versions: Python 3.10, Python 3.11, Python 3.6, Python 3.7, Python 3.8, Python 
3.9

___
Python tracker 

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