Skip to content

Python IDLE context "Edit with IDLE" fails if there is a threading.py in the same folder #103967

Closed as not planned

Description

@xqt

Bug report

Steps to replicate the issue:

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

Activity

  1. added
    type-bug
    on Apr 28, 2023
  2. sunmy2019 commented on Apr 28, 2023

    @sunmy2019
    Member

    It sounds like somewhere is importing threading, and your threading.py was found instead of the system.

  3. xqt commented on Apr 28, 2023

    @xqt
    Author

    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

  4. Eclips4 commented on Apr 28, 2023

    @Eclips4
    Member

    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

    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

  5. terryjreedy commented on Apr 28, 2023

    @terryjreedy
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions