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

Incorrect iteration of Manager.dict() method of the multiprocessing module. #78791

Closed
deltaclock mannequin opened this issue Sep 7, 2018 · 6 comments
Closed

Incorrect iteration of Manager.dict() method of the multiprocessing module. #78791

deltaclock mannequin opened this issue Sep 7, 2018 · 6 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@deltaclock
Copy link
Mannequin

deltaclock mannequin commented Sep 7, 2018

BPO 34610
Nosy @pitrou, @benjaminp, @serhiy-storchaka, @applio, @miss-islington, @deltaclock
PRs
  • bpo-34610: Fixed iterator of multiprocessing.managers.DictProxy. #9113
  • [3.7] bpo-34610: Fixed iterator of multiprocessing.managers.DictProxy. (GH-9113) #9349
  • [3.6] bpo-34610: Fixed iterator of multiprocessing.managers.DictProxy. (GH-9113) #9350
  • [2.7] bpo-34610: Fixed iterator of multiprocessing.managers.DictProxy (GH-9113). #9500
  • Files
  • test.py: Proof of concept code.
  • 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 = None
    closed_at = <Date 2018-09-22.18:35:26.970>
    created_at = <Date 2018-09-07.23:43:37.917>
    labels = ['3.7', '3.8', 'type-bug', 'library']
    title = 'Incorrect iteration of Manager.dict() method of the multiprocessing module.'
    updated_at = <Date 2018-09-22.18:35:26.969>
    user = 'https://github.com/deltaclock'

    bugs.python.org fields:

    activity = <Date 2018-09-22.18:35:26.969>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-09-22.18:35:26.970>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2018-09-07.23:43:37.917>
    creator = 'deltaclock'
    dependencies = []
    files = ['47792']
    hgrepos = []
    issue_num = 34610
    keywords = ['patch']
    message_count = 6.0
    messages = ['324813', '324820', '325522', '325528', '325529', '326107']
    nosy_count = 6.0
    nosy_names = ['pitrou', 'benjamin.peterson', 'serhiy.storchaka', 'davin', 'miss-islington', 'deltaclock']
    pr_nums = ['9113', '9349', '9350', '9500']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue34610'
    versions = ['Python 2.7', 'Python 3.6', 'Python 3.7', 'Python 3.8']

    @deltaclock
    Copy link
    Mannequin Author

    deltaclock mannequin commented Sep 7, 2018

    The manager class of the multiprocessing module doesnt implement __next__ or __iter__ on its dictionary method and relies on using __getitem__.

    This results in an unexpected functionality of an object that is supposed to act like a dict, and instead of looping over the dictionary keys it loops over its values.

    The user needs to call dict() on this object in order to loop over it correctly, which is not that obvious.

    The problem originates from there https://github.com/python/cpython/blob/master/Lib/multiprocessing/managers.py#L1136

    Poc link: https://hastebin.com/codoqihowi.py

    @deltaclock deltaclock mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Sep 7, 2018
    @serhiy-storchaka
    Copy link
    Member

    DictProxy needs to provide the __iter__() method. And perhaps methods keys(), values() and items() need to be reworked in Python 3. has_key() is unneeded in Python 3.

    It is worth to test also other special and new in Python 3 methods.

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life 3.8 only security fixes labels Sep 8, 2018
    @serhiy-storchaka
    Copy link
    Member

    New changeset e0e5065 by Serhiy Storchaka in branch 'master':
    bpo-34610: Fixed iterator of multiprocessing.managers.DictProxy. (GH-9113)
    e0e5065

    @miss-islington
    Copy link
    Contributor

    New changeset 1d30788 by Miss Islington (bot) in branch '3.7':
    bpo-34610: Fixed iterator of multiprocessing.managers.DictProxy. (GH-9113)
    1d30788

    @miss-islington
    Copy link
    Contributor

    New changeset f35e4d5 by Miss Islington (bot) in branch '3.6':
    bpo-34610: Fixed iterator of multiprocessing.managers.DictProxy. (GH-9113)
    f35e4d5

    @serhiy-storchaka
    Copy link
    Member

    New changeset 69d0bc1 by Serhiy Storchaka in branch '2.7':
    [2.7] bpo-34610: Fixed iterator of multiprocessing.managers.DictProxy. (GH-9113). (GH-9500)
    69d0bc1

    @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 stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants