Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make idlelib/run.py runnable. #81219

Closed
terryjreedy opened this issue May 24, 2019 · 5 comments
Closed

Make idlelib/run.py runnable. #81219

terryjreedy opened this issue May 24, 2019 · 5 comments
Assignees
Labels
3.7 (EOL) end of life 3.8 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error

Comments

@terryjreedy
Copy link
Member

BPO 37038
Nosy @terryjreedy, @taleinat, @miss-islington
PRs
  • bpo-37038: Make idlelib.run runnable; add test clause #13560
  • [3.7] bpo-37038: Make idlelib.run runnable; add test clause (GH-13560) #13561
  • 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 2019-06-11.05:54:03.314>
    created_at = <Date 2019-05-24.21:56:19.960>
    labels = ['3.8', 'expert-IDLE', 'type-bug', '3.7']
    title = 'Make idlelib/run.py runnable.'
    updated_at = <Date 2019-06-11.05:54:03.313>
    user = 'https://github.com/terryjreedy'

    bugs.python.org fields:

    activity = <Date 2019-06-11.05:54:03.313>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2019-06-11.05:54:03.314>
    closer = 'terry.reedy'
    components = ['IDLE']
    creation = <Date 2019-05-24.21:56:19.960>
    creator = 'terry.reedy'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37038
    keywords = ['patch']
    message_count = 5.0
    messages = ['343433', '343449', '343453', '345184', '345188']
    nosy_count = 3.0
    nosy_names = ['terry.reedy', 'taleinat', 'miss-islington']
    pr_nums = ['13560', '13561']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue37038'
    versions = ['Python 3.7', 'Python 3.8']

    @terryjreedy
    Copy link
    Member Author

    Slightly simplified, pyshell.ModifiedInterpreter.built_subprocess runs
    f'{sys.executable} -c "__import__('idlelib.run').run.main()"'.
    "__import__('idlelib.run')" creates sys.modules['idlelib'] from idlelib/init.py, creates sys.modules['idlelib.run'] from idlelib/run.py, binds 'run' to the idlelib.run module in the idlelib module, and returns the idlelib module. It does not bind any names in the main module of the new process. '.run' gets the idlelib.run module and '.main()' executes its main function. This eventually executes user code in the so-far untouched main module.

    During the creation of the idlelib.run module, various other idlelib module are imported. Some of these import both tkinter and its submodules, such as tkinter.font, adding names such as 'font' to the tkinter modules. To prevent user code running when it should not, these added names are deleted. bpo-25507.

    Once the deletion code is run, it will fail with AttributeError if run again, such as from an IDLE editor. The patch solves this by adding a flag that indicates that the file has already be imported into the process.

    @terryjreedy terryjreedy added 3.7 (EOL) end of life 3.8 only security fixes labels May 24, 2019
    @terryjreedy terryjreedy self-assigned this May 24, 2019
    @terryjreedy terryjreedy added topic-IDLE type-bug An unexpected behavior, bug, or error labels May 24, 2019
    @terryjreedy
    Copy link
    Member Author

    New changeset 81bb97d by Terry Jan Reedy in branch 'master':
    bpo-37038: Make idlelib.run runnable; add test clause (GH-13560)
    81bb97d

    @miss-islington
    Copy link
    Contributor

    New changeset c70ab1c by Miss Islington (bot) in branch '3.7':
    bpo-37038: Make idlelib.run runnable; add test clause (GH-13560)
    c70ab1c

    @taleinat
    Copy link
    Contributor

    Terry, I believe this can be closed now that the fix has been merged?

    @terryjreedy
    Copy link
    Member Author

    Yes, thank you.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants