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

Terry J. Reedy report at bugs.python.org
Thu Oct 21 20:17:38 EDT 2021


Terry J. Reedy <tjreedy at udel.edu> 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 <report at bugs.python.org>
<https://bugs.python.org/issue45560>
_______________________________________


More information about the Python-bugs-list mailing list