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

functools.partial is not compatible between 2.7 and 3.5 #73718

Closed
naoyuki-kamo mannequin opened this issue Feb 11, 2017 · 8 comments
Closed

functools.partial is not compatible between 2.7 and 3.5 #73718

naoyuki-kamo mannequin opened this issue Feb 11, 2017 · 8 comments
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@naoyuki-kamo
Copy link
Mannequin

naoyuki-kamo mannequin commented Feb 11, 2017

BPO 29532
Nosy @rhettinger, @stevendaprano, @methane, @serhiy-storchaka, @naoyuki-kamo
PRs
  • bpo-29532: Altering a kwarg dictionary passed to functools.partial() #190
  • [3.6] bpo-29532: Altering a kwarg dictionary passed to functools.partial() no longer affects a partial object after creation. #198
  • [3.6] bpo-29532: Altering a kwarg dictionary passed to functools.partial() … #209
  • [3.5] bpo-29532: Altering a kwarg dictionary passed to functools.partial() no longer affects a partial object after creation. #222
  • [Do Not Merge] Sample of CPython life with blurb. #703
  • [Do Not Merge] Convert Misc/NEWS so that it is managed by towncrier #552
  • Files
  • partial-copy-kwargs.patch
  • 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 2017-02-22.09:53:25.891>
    created_at = <Date 2017-02-11.07:20:01.590>
    labels = ['3.7', 'type-bug', 'library']
    title = 'functools.partial is not compatible between 2.7 and 3.5'
    updated_at = <Date 2017-03-31.16:36:21.417>
    user = 'https://github.com/naoyuki-kamo'

    bugs.python.org fields:

    activity = <Date 2017-03-31.16:36:21.417>
    actor = 'dstufft'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-02-22.09:53:25.891>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2017-02-11.07:20:01.590>
    creator = 'naoyuki'
    dependencies = []
    files = ['46633']
    hgrepos = []
    issue_num = 29532
    keywords = ['patch']
    message_count = 8.0
    messages = ['287594', '287595', '287598', '287673', '287832', '288197', '288309', '288347']
    nosy_count = 5.0
    nosy_names = ['rhettinger', 'steven.daprano', 'methane', 'serhiy.storchaka', 'naoyuki']
    pr_nums = ['190', '198', '209', '222', '703', '552']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue29532'
    versions = ['Python 3.5', 'Python 3.6', 'Python 3.7']

    @naoyuki-kamo
    Copy link
    Mannequin Author

    naoyuki-kamo mannequin commented Feb 11, 2017

    The code:
    from functools import partial
    def f(a):
    print(a)
    d = {'a': 3}
    g = partial(f, **d)
    g()
    d['a'] = 5
    g()

    On python2.7, gets
    3
    but on python3.5, gets
    5

    is it a bug?

    @naoyuki-kamo naoyuki-kamo mannequin added the type-bug An unexpected behavior, bug, or error label Feb 11, 2017
    @stevendaprano
    Copy link
    Member

    Confirmed that in Python 2.7 calling g() before and after modifying the dict prints 3 both times; calling g() before modifying the dict prints 3, then after modifying it prints 5.

    Python 3.3 behaves like 2.7, so this sounds like a regression in 3.5 or maybe 3.4.

    @serhiy-storchaka
    Copy link
    Member

    Yes, this can be considered a bug. Following patch fixes it.

    @serhiy-storchaka serhiy-storchaka added stdlib Python modules in the Lib dir 3.7 (EOL) end of life labels Feb 11, 2017
    @methane
    Copy link
    Member

    methane commented Feb 13, 2017

    patch LGTM.

    @rhettinger
    Copy link
    Contributor

    Agree that this is a bug. Patch and test looks good.

    @serhiy-storchaka
    Copy link
    Member

    New changeset 9639e4a by GitHub in branch 'master':
    bpo-29532: Altering a kwarg dictionary passed to functools.partial() (#190)
    9639e4a

    @serhiy-storchaka
    Copy link
    Member

    New changeset e48fd93 by GitHub in branch '3.6':
    bpo-29532: Altering a kwarg dictionary passed to functools.partial() no longer affects a partial object after creation. (#209)
    e48fd93

    @serhiy-storchaka
    Copy link
    Member

    New changeset 5010a77 by GitHub in branch '3.5':
    [3.5] bpo-29532: Altering a kwarg dictionary passed to functools.partial() no longer affects a partial object after creation. (#222)
    5010a77

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

    No branches or pull requests

    4 participants