[New-bugs-announce] [issue37038] Make idlelib/run.py runnable.

Terry J. Reedy report at bugs.python.org
Fri May 24 17:56:19 EDT 2019


New submission from Terry J. Reedy <tjreedy at udel.edu>:

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 <report at bugs.python.org>
<https://bugs.python.org/issue37038>
_______________________________________


More information about the New-bugs-announce mailing list