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

IDLE: add current directory to open_module #62264

Open
terryjreedy opened this issue May 25, 2013 · 3 comments
Open

IDLE: add current directory to open_module #62264

terryjreedy opened this issue May 25, 2013 · 3 comments
Assignees
Labels
3.10 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error

Comments

@terryjreedy
Copy link
Member

BPO 18064
Nosy @terryjreedy, @serwy, @roseman
Dependencies
  • bpo-18055: Stop using imp in IDLE
  • 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 = None
    created_at = <Date 2013-05-25.21:36:20.538>
    labels = ['expert-IDLE', 'type-bug', '3.10']
    title = 'IDLE: add current directory to open_module'
    updated_at = <Date 2020-06-06.22:20:53.253>
    user = 'https://github.com/terryjreedy'

    bugs.python.org fields:

    activity = <Date 2020-06-06.22:20:53.253>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = False
    closed_date = None
    closer = None
    components = ['IDLE']
    creation = <Date 2013-05-25.21:36:20.538>
    creator = 'terry.reedy'
    dependencies = ['18055']
    files = []
    hgrepos = []
    issue_num = 18064
    keywords = []
    message_count = 3.0
    messages = ['190012', '190057', '296372']
    nosy_count = 3.0
    nosy_names = ['terry.reedy', 'roger.serwy', 'markroseman']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'test needed'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue18064'
    versions = ['Python 3.10']

    @terryjreedy
    Copy link
    Member Author

    The point of File / Open Module is to look at the source for a module that has been, could be, or will be imported. The problem is that open_module is executed in the idle process while imports are executed in the user process, with the current directory prepended to sys.module.
    The problem was already noted in the source, line 675.
    # XXX Ought to insert current file's directory in front of path

    The augmentation of sys.path and subsequent restoration of the original could be done in a context manager that might be useful elsewhere. For 3.3,3.4, I think the change should be done after the patch in bpo-18055, to not invalidate that patch. It would need to located in a slightly different place in 2.7, which will not be changed by that issue.

    @terryjreedy terryjreedy added the type-bug An unexpected behavior, bug, or error label May 25, 2013
    @terryjreedy
    Copy link
    Member Author

    Code also suggests that this function should be elsewhere, such as in iobinding. This should be in the same place as regular open, wherever that is, since it is an alternative open.

    Document should be upgraded a bit: "Load module opens Python-coded modules on sys.path in an editor window. The default name is the currently selected text, if any."

    Tests should be added with this issue. This is the smallest dialog, and the structure of the revised code (bpo-18055) gives a skeleton for a testcase: test_python_module (window open), test_builtin_module (Exception), test_bad_path (different Exception), and maybe even test_bad loader. We should look at tkinter tests for simulating name entry and click.

    @terryjreedy
    Copy link
    Member Author

    For IDLE development, I would love to have idlelib and idlelib.idle_test on the open line. Perhaps this should be user configurable: Favorite directories for opening files.

    @terryjreedy terryjreedy self-assigned this Jun 19, 2017
    @terryjreedy terryjreedy added 3.10 only security fixes and removed 3.7 (EOL) end of life labels Jun 6, 2020
    @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.10 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error
    Projects
    Status: No status
    Development

    No branches or pull requests

    1 participant