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

Use dict unpacking in idlelib #80586

Closed
terryjreedy opened this issue Mar 23, 2019 · 11 comments
Closed

Use dict unpacking in idlelib #80586

terryjreedy opened this issue Mar 23, 2019 · 11 comments
Assignees
Labels
3.7 (EOL) end of life 3.8 only security fixes topic-IDLE type-feature A feature request or enhancement

Comments

@terryjreedy
Copy link
Member

BPO 36405
Nosy @terryjreedy, @serhiy-storchaka, @miss-islington
PRs
  • bpo-36405: Use dict unpacking in idlelib #12507
  • [3.7] bpo-36405: Use dict unpacking in idlelib (GH-12507) #12510
  • bpo-36405: IDLE - Restore __main__ and add tests #12518
  • [3.7] bpo-36405: IDLE - Restore __main__ and add tests (GH-12518) #12526
  • 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-03-24.21:44:05.550>
    created_at = <Date 2019-03-23.05:43:09.360>
    labels = ['3.8', 'expert-IDLE', 'type-feature', '3.7']
    title = 'Use dict unpacking in idlelib'
    updated_at = <Date 2019-03-24.23:10:32.823>
    user = 'https://github.com/terryjreedy'

    bugs.python.org fields:

    activity = <Date 2019-03-24.23:10:32.823>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2019-03-24.21:44:05.550>
    closer = 'terry.reedy'
    components = ['IDLE']
    creation = <Date 2019-03-23.05:43:09.360>
    creator = 'terry.reedy'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 36405
    keywords = ['patch']
    message_count = 11.0
    messages = ['338643', '338648', '338655', '338656', '338657', '338659', '338661', '338702', '338755', '338757', '338765']
    nosy_count = 3.0
    nosy_names = ['terry.reedy', 'serhiy.storchaka', 'miss-islington']
    pr_nums = ['12507', '12510', '12518', '12526']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue36405'
    versions = ['Python 3.7', 'Python 3.8']

    @terryjreedy
    Copy link
    Member Author

    Replace 3 occurrences of 'd = d1.copy(); d.update(d2)' pattern with 'd = {**d1, **d2}'. Also remove unnecessary imports and uses of __main__.

    @terryjreedy terryjreedy added 3.7 (EOL) end of life 3.8 only security fixes labels Mar 23, 2019
    @terryjreedy terryjreedy self-assigned this Mar 23, 2019
    @terryjreedy terryjreedy added topic-IDLE type-feature A feature request or enhancement labels Mar 23, 2019
    @serhiy-storchaka
    Copy link
    Member

    It is not unnecessary. globals() is not the same as __main__.__dict__.

    It may be possible to use a ChainMap instead of merging dicts, but I do not think it matters.

    @terryjreedy
    Copy link
    Member Author

    New changeset 2b75155 by Terry Jan Reedy in branch 'master':
    bpo-36405: Use dict unpacking in idlelib (bpo-12507)
    2b75155

    @terryjreedy
    Copy link
    Member Author

    I hit merge before seeing your post here. I based the globals change on

    >>> import __main__
    >>> __main__.__dict__ is globals()
    True

    @serhiy-storchaka
    Copy link
    Member

    It is true only in the main script or REPL. But you executed that code in imported modules.

    @miss-islington
    Copy link
    Contributor

    New changeset 00986ec by Miss Islington (bot) in branch '3.7':
    bpo-36405: Use dict unpacking in idlelib (GH-12507)
    00986ec

    @terryjreedy
    Copy link
    Member Author

    You mean that the patch will execute the code in imported module where the two are not even equal. So I will revert the '__main__' changes.

    I found two differences in completion behavior with the patch. One is a failure that should work, another is a success that should fail. I will try to turn at least one of them into a new test that fails before the reversion and passes after.

    @terryjreedy
    Copy link
    Member Author

    Also, __builtins__ is only a module, with a __dict__, in __main__.

    @terryjreedy
    Copy link
    Member Author

    New changeset 0fe4513 by Terry Jan Reedy in branch 'master':
    bpo-36405: IDLE - Restore __main__ and add tests (bpo-12518)
    0fe4513

    @miss-islington
    Copy link
    Contributor

    New changeset 2b58014 by Miss Islington (bot) in branch '3.7':
    bpo-36405: IDLE - Restore __main__ and add tests (GH-12518)
    2b58014

    @terryjreedy
    Copy link
    Member Author

    Immediate followup is bpo-30348, add autocomplete tests. At least one would have failed with the initial patch.

    @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-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants