Skip to content

Idle, 2.7, backport idlelib.__main__, enable py -m idlelib #68400

Closed

Description

@terryjreedy
BPO 24212
Nosy @terryjreedy, @serhiy-storchaka

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/terryjreedy'
closed_at = <Date 2017-06-19.21:42:32.885>
created_at = <Date 2015-05-16.21:46:53.214>
labels = ['expert-IDLE', 'type-bug']
title = 'Idle, 2.7, backport idlelib.__main__, enable py -m idlelib'
updated_at = <Date 2017-09-01.12:26:22.525>
user = 'https://github.com/terryjreedy'

bugs.python.org fields:

activity = <Date 2017-09-01.12:26:22.525>
actor = 'terry.reedy'
assignee = 'terry.reedy'
closed = True
closed_date = <Date 2017-06-19.21:42:32.885>
closer = 'terry.reedy'
components = ['IDLE']
creation = <Date 2015-05-16.21:46:53.214>
creator = 'terry.reedy'
dependencies = []
files = []
hgrepos = []
issue_num = 24212
keywords = []
message_count = 7.0
messages = ['243369', '243373', '243385', '243409', '296379', '296384', '301095']
nosy_count = 4.0
nosy_names = ['terry.reedy', 'Arfrever', 'python-dev', 'serhiy.storchaka']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue24212'
versions = ['Python 2.7']

Linked PRs

Activity

  1. terryjreedy commented on May 16, 2015

    @terryjreedy
    MemberAuthor

    Discussion on another issue suggested that 3.x idlelib.__main__ be backported to 2.7 so 'python -m idlelib would work with 2.7 as with 3.x. The current file:

    """
    IDLE main entry point
    Run IDLE as python -m idlelib
    """
    import idlelib.PyShell
    idlelib.PyShell.main()

    When I tried this, it failed two ways.

    1. The AutoComplete and CallTips extensions did not import properly. The error messages are printed from the except clause in EditorWindow.load_standard_extensions. I presume this call results from "import EditorWindow" in PyShell.
    Failed to load extension 'AutoComplete'
    Traceback (most recent call last):
      File "C:\Programs\Python27\lib\idlelib\EditorWindow.py", line 1068, in load_standard_extensions
        self.load_extension(name)
      File "C:\Programs\Python27\lib\idlelib\EditorWindow.py", line 1083, in load_extension
        cls = getattr(mod, name)
    AttributeError: 'module' object has no attribute 'AutoComplete'

    Somehow AutoComplete was imported without an ImportError even though the class AutoComplete statement did not create the class asstribute.

    AutoComplete and CallTips are the two extensions containing "import __main__". Adding idlelib.__main__ somehow causes weird behavior in 2.7, though not in 3.x. Commenting out these imports removes the import problem.

    1. Even with 1 temporarily fixed with '#', an unsaved file 'named' C:\users\terry\NNNNN.py is open in an editor window. ("Unsaved' and'named' areusually mutually exclusive.) Two shell windows, instead of one, are opened. One fails to connect to a subprocess. Clicking away the message box raises SystemExit.

    Changing __main__.py to ...
    from idlelib.PyShell import *
    main()

    had no effect.

    I will add a reference to this issue in the file. (If should be removed if this issue is fixed.)

  2. python-dev commented on May 16, 2015

    python-devmannequin
    Mannequin

    New changeset 44fc6db34b69 by Terry Jan Reedy in branch '3.4':
    Issue bpo-24212: Put reference in idle.__main__ to issue with explanation.
    https://hg.python.org/cpython/rev/44fc6db34b69

  3. serhiy-storchaka commented on May 17, 2015

    @serhiy-storchaka
    Member

    Why idlelib.__main__ should be backported? You can start IDLE as "python -m idlelib.idle" in 2.7 and this works as well in 3.x.

  4. terryjreedy commented on May 17, 2015

    @terryjreedy
    MemberAuthor

    The idea, obviously, is for python -m idlelib to also work on all systems. When this was requested as part of the discussion on another issue, I thought there was no idlelib.__main__ because __main__ did not work on 2.7. Someone corrected me and the expectation of me and others was that the absence was just an easily corrected oversight. Turns out not so. I wanted to at least document that the backport is not trivial. I am rather curious why the same code behaves so differently on 2.7.

  5. terryjreedy commented on Jun 19, 2017

    @terryjreedy
    MemberAuthor

    I am no longer patching IDLE for 2.7.

  6. self-assigned this
    on Jun 19, 2017
  7. terryjreedy commented on Jun 19, 2017

    @terryjreedy
    MemberAuthor

    I wanted this for the same reason you backported test.__main__ in bpo-30223, but I'm not going to fix the problems.

  8. terryjreedy commented on Sep 1, 2017

    @terryjreedy
    MemberAuthor

    bpo-27099 converts extensions, including autocomplete and calltips, to features. Buggy versions of the patch had similar import problems. After the PR is merged, I may try this again, and perhaps try moving the __main__ import into the functions that use it.

  9. transferred this issue fromon Apr 10, 2022
  10. StanFromIreland commented on Feb 9, 2025

    @StanFromIreland
    Member

    # This file does not work for 2.7; See issue 24212.

    Should this be updated to the github issue no #68400? Or this comment can just be removed as 2.7 is long gone.

  11. terryjreedy commented on Feb 9, 2025

    @terryjreedy
    MemberAuthor

    Remove comment.

  12. StanFromIreland commented on Feb 9, 2025

    @StanFromIreland
    Member

    Complete.

  13. added a commit that references this issue on Feb 10, 2025
  14. added 2 commits that reference this issue on Feb 10, 2025
  15. added 2 commits that reference this issue on Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

topic-IDLEtype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions