You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
functools.partial is not compatible between 2.7 and 3.5 #73718
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=Noneclosed_at=<Date2017-02-22.09:53:25.891>created_at=<Date2017-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=<Date2017-03-31.16:36:21.417>user='https://github.com/naoyuki-kamo'
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.
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
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
Activity
naoyuki-kamo commentedon 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?
stevendaprano commentedon Feb 11, 2017
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 commentedon Feb 11, 2017
Yes, this can be considered a bug. Following patch fixes it.
methane commentedon Feb 13, 2017
patch LGTM.
rhettinger commentedon Feb 15, 2017
Agree that this is a bug. Patch and test looks good.
serhiy-storchaka commentedon Feb 20, 2017
New changeset 9639e4a by GitHub in branch 'master':
bpo-29532: Altering a kwarg dictionary passed to functools.partial() (#190)
9639e4a
serhiy-storchaka commentedon Feb 21, 2017
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 commentedon Feb 22, 2017
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