Skip to content

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

Closed

Description

@naoyuki-kamo
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']

    Activity

    1. naoyuki-kamo commented on Feb 11, 2017

      naoyuki-kamomannequin
      MannequinAuthor

      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?

    2. stevendaprano commented on Feb 11, 2017

      @stevendaprano
      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.

    3. serhiy-storchaka commented on Feb 11, 2017

      @serhiy-storchaka
      Member

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

    4. methane commented on Feb 13, 2017

      @methane
      Member

      patch LGTM.

    5. rhettinger commented on Feb 15, 2017

      @rhettinger
      Contributor

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

    6. serhiy-storchaka commented on Feb 20, 2017

      @serhiy-storchaka
      Member

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

    7. serhiy-storchaka commented on Feb 21, 2017

      @serhiy-storchaka
      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

    8. serhiy-storchaka commented on Feb 22, 2017

      @serhiy-storchaka
      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

    9. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.7 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions