Skip to content

gh-134300: Remove idlelib from the path of the IDLE user process#152739

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-134300-idlelib-syspath
Open

gh-134300: Remove idlelib from the path of the IDLE user process#152739
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-134300-idlelib-syspath

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jul 1, 2026

Copy link
Copy Markdown
Member

When idle.py is run as a script, its directory (.../idlelib) is placed on sys.path[0]. ModifiedInterpreter.transfer_path() then sends the whole GUI sys.path to the user subprocess (replacing its sys.path), so user code could import idlelib submodules as top-level modules, e.g. import help silently imports idlelib.help. A subissue of #69674.

transfer_path() now removes the idlelib directory from the transferred path. Only that entry is removed, so import idlelib.run and the other idlelib modules the subprocess needs still resolve via the Lib parent directory; as Terry noted in the issue, idlelib.run runs fine without idlelib on the path.

The removal is factored into a module-level fix_user_path() with a non-GUI unit test.

🤖 Generated with Claude Code

The idlelib directory ends up on sys.path when idle.py is run as a script,
and it was passed to the user process, where it let user code import
idlelib submodules as top-level modules, such as "import help".
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant