mirror of
https://github.com/python/cpython
synced 2026-11-13 18:26:43 +03:00
gh-70331: Protect IDLE's imports from user files in the current directory (GH-157643)
Start the user process with -P, so that the current directory is not on
sys.path while idlelib.run and its dependencies are imported. sys.path
is set later by transfer_path(). Protect __main__, idle, and pyshell entry points.
(cherry picked from commit 6893326350)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
14 lines
296 B
Python
14 lines
296 B
Python
"""
|
|
IDLE main entry point
|
|
|
|
Run IDLE as python -m idlelib
|
|
"""
|
|
import sys
|
|
|
|
if not sys.flags.safe_path:
|
|
# Remove the current directory, prepended by "python -m", so that
|
|
# user files do not shadow IDLE's imports (gh-70331).
|
|
del sys.path[0]
|
|
|
|
import idlelib.pyshell
|
|
idlelib.pyshell.main()
|