New submission from Terry J. Reedy <[email protected]>:
Slightly simplified, pyshell.ModifiedInterpreter.built_subprocess runs
f'{sys.executable} -c "__import__('idlelib.run').run.main()"'.
"__import__('idlelib.run')" creates sys.modules['idlelib'] from
idlelib/__init__.py, creates sys.modules['idlelib.run'] from idlelib/run.py,
binds 'run' to the idlelib.run module in the idlelib module, and returns the
idlelib module. It does not bind any names in the main module of the new
process. '.run' gets the idlelib.run module and '.main()' executes its main
function. This eventually executes user code in the so-far untouched main
module.
During the creation of the idlelib.run module, various other idlelib module are
imported. Some of these import both tkinter and its submodules, such as
tkinter.font, adding names such as 'font' to the tkinter modules. To prevent
user code running when it should not, these added names are deleted. #25507.
Once the deletion code is run, it will fail with AttributeError if run again,
such as from an IDLE editor. The patch solves this by adding a flag that
indicates that the file has already be imported into the process.
----------
assignee: terry.reedy
components: IDLE
messages: 343433
nosy: terry.reedy
priority: normal
severity: normal
stage: needs patch
status: open
title: Make idlelib/run.py runnable.
type: behavior
versions: Python 3.7, Python 3.8
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue37038>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com