Description
When use IDLE to open a file and start a new IDLE windows from "Python Shell" button, you can import the modules that are the child modules in the module "idlelib", such as "help", "pyshell". Think for that there are many schools still use IDLE to teach python to prevent the students to install malicious plugins from other IDE, if the students try to import these modules, it will result in misleading.
import help
This code is wrong in cmd and any other IDE but "normal" in IDLE, and what is imported is "idlelib.help".
Activity
gaogaotiantian commentedon May 20, 2025
Hi, there's a quick suggestion - the title of the issue should be more descriptive about the topic, rather than a very generic question, so the triagers and core devs can understand what's the issue about (whether it's in their area of expertise) without clicking into it.
picnixz commentedon May 20, 2025
cc @terryjreedy I don't understand the issue but since it seems to be IDLE related, I'm pinging you to have a look and decide the scope.
ronaldoussoren commentedon May 20, 2025
Which version of Python are you using? And what OS are you on?
On macOS I get:
terryjreedy commentedon May 20, 2025
This is a subissue of #69674; I am leaving this open to patch this specific issue, which is that
.../idlelib
is sometimes on sys.path in the separate user process where user code is normally executed. ('Normally', means when option-n
is not added to IDLE startup.) I noted in 2015 that this depends on how IDLE is started; and added today that it may have changed with version. It also depends the system. With 3.14 on my Win 10,>>> import help
works. On my macbook with Catalina, it raises as Ronald shows above. (Note to anyone else: the splash lineEnter "help" below ...
is IDLE Shell specific.) Checking sys.path (most easily withfor p in sys.path: print(p)
shows that.../idlelib
is present on Windows but not on Mac.@Locked-chess-official What OS, python version, and IDLE startup method did you use.
I think adding the following to idlelib.run near the top should work.
[-]Is it needs to be fixed or writed in docs for warning?[/-][+]Remove idlelib from sys.path in IDLE run process[/+]Locked-chess-official commentedon May 21, 2025
Windows, 3.12 and 3.13
Locked-chess-official commentedon May 21, 2025