You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python IDLE context "Edit with IDLE" fails if there is a threading.py in the same folder #103967
Add a threading.py script (which may be empty). Right-click the script with context menu "Edit with IDLE".
Try to open another Python script which resides in the same folder in that way.
What happens?:
No file can be opened with IDLE context menu but a __pycache__ was created with a compiled threading Python file in both cases.
When removing the threading.py the IDLE context menu works again.
What should have happened instead?:
The threading.py should not be compiled but the selected script should be opened.
Your environment
CPython versions tested on: //Python: 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)]//
Operating system and architecture: //Microsoft Windows [Version 10.0.17763.1577]//
It also fails for Python 3.12a7 and I guess for 3.10 but I believe it worked for Python 3.9 and below.
Enclosed the compiled file for an empty threading.py: pycache.zip
It sounds like somewhere is importing threading, and your threading.py was found instead of the system.
I found some other script names where IDLE tries to import the local script instead of the system: idlelib.py, pickle.py, queue.py, re.py, textwrap.py, tokenize.py
I found some other script names where IDLE tries to import the local script instead of the system: idlelib.py, pickle.py, queue.py, re.py, textwrap.py, tokenize.py
It is somewhat a bug for users to make files duplicating stdlib names unless they want such files to replace the standard files. It is also somewhat a bug that IDLE does not currently protect itself against such user bugs. But doing so without potentially breaking user code is not trivial, as explained in #70331. (However, I just posted there a specific ideas for fixing IDLE's normal mode of executing user code.) Closing as partly not a bug and partly a duplicate of an existing bug issue.
Activity
sunmy2019 commentedon Apr 28, 2023
It sounds like somewhere is importing
threading, and yourthreading.pywas found instead of the system.xqt commentedon Apr 28, 2023
I found some other script names where IDLE tries to import the local script instead of the system: idlelib.py, pickle.py, queue.py, re.py, textwrap.py, tokenize.py
Eclips4 commentedon Apr 28, 2023
Hello!
Yeah, this modules is used by IDLE, so, when IDLE is initializing, it is try to import some modules, for internal use.
Please read this: https://docs.python.org/3/reference/import.html#importsystem
terryjreedy commentedon Apr 28, 2023
It is somewhat a bug for users to make files duplicating stdlib names unless they want such files to replace the standard files. It is also somewhat a bug that IDLE does not currently protect itself against such user bugs. But doing so without potentially breaking user code is not trivial, as explained in #70331. (However, I just posted there a specific ideas for fixing IDLE's normal mode of executing user code.) Closing as partly not a bug and partly a duplicate of an existing bug issue.