Issue 29532: functools.partial is not compatible between 2.7 and 3.5
Created on 2017-02-11 07:20 by naoyuki, last changed 2022-04-11 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| partial-copy-kwargs.patch | serhiy.storchaka, 2017-02-11 11:10 | review | ||
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 190 | merged | serhiy.storchaka, 2017-02-20 09:08 | |
| PR 198 | closed | serhiy.storchaka, 2017-02-20 12:17 | |
| PR 209 | open | serhiy.storchaka, 2017-02-21 06:25 | |
| PR 222 | merged | serhiy.storchaka, 2017-02-21 20:42 | |
| PR 703 | larry, 2017-03-17 21:00 | ||
| PR 552 | closed | dstufft, 2017-03-31 16:36 | |
| Messages (8) | |||
|---|---|---|---|
| msg287594 - (view) | Author: Naoyuki Kamo (naoyuki) | Date: 2017-02-11 07:20 | |
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?
|
|||
| msg287595 - (view) | Author: Steven D'Aprano (steven.daprano) * ![]() |
Date: 2017-02-11 08:26 | |
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. |
|||
| msg287598 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2017-02-11 11:10 | |
Yes, this can be considered a bug. Following patch fixes it. |
|||
| msg287673 - (view) | Author: Inada Naoki (methane) * ![]() |
Date: 2017-02-13 10:33 | |
patch LGTM. |
|||
| msg287832 - (view) | Author: Raymond Hettinger (rhettinger) * ![]() |
Date: 2017-02-15 09:51 | |
Agree that this is a bug. Patch and test looks good. |
|||
| msg288197 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2017-02-20 12:04 | |
New changeset 9639e4ab6d5bd3ca0ab34fef127e9fc84b6b88b9 by GitHub in branch 'master': bpo-29532: Altering a kwarg dictionary passed to functools.partial() (#190) https://github.com/python/cpython/commit/9639e4ab6d5bd3ca0ab34fef127e9fc84b6b88b9 |
|||
| msg288309 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2017-02-21 16:18 | |
New changeset e48fd93bbb36c6d80aa4eb6af09f58c69d8cf965 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) https://github.com/python/cpython/commit/e48fd93bbb36c6d80aa4eb6af09f58c69d8cf965 |
|||
| msg288347 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2017-02-22 09:46 | |
New changeset 5010a77a4da76d8d3fd861a63a7f1ce8f0e9c520 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) https://github.com/python/cpython/commit/5010a77a4da76d8d3fd861a63a7f1ce8f0e9c520 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:43 | admin | set | github: 73718 |
| 2017-03-31 16:36:21 | dstufft | set | pull_requests: + pull_request950 |
| 2017-03-17 21:00:35 | larry | set | pull_requests: + pull_request612 |
| 2017-02-22 09:53:25 | serhiy.storchaka | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2017-02-22 09:46:35 | serhiy.storchaka | set | messages: + msg288347 |
| 2017-02-21 20:42:50 | serhiy.storchaka | set | pull_requests: + pull_request186 |
| 2017-02-21 16:18:31 | serhiy.storchaka | set | messages: + msg288309 |
| 2017-02-21 06:25:22 | serhiy.storchaka | set | pull_requests: + pull_request178 |
| 2017-02-20 12:17:41 | serhiy.storchaka | set | pull_requests: + pull_request165 |
| 2017-02-20 12:04:32 | serhiy.storchaka | set | messages: + msg288197 |
| 2017-02-20 09:08:20 | serhiy.storchaka | set | pull_requests: + pull_request156 |
| 2017-02-15 09:51:49 | rhettinger | set | nosy:
+ rhettinger messages: + msg287832 |
| 2017-02-13 10:33:33 | methane | set | nosy:
+ methane messages: + msg287673 |
| 2017-02-11 11:10:13 | serhiy.storchaka | set | files:
+ partial-copy-kwargs.patch components:
+ Library (Lib) messages:
+ msg287598 |
| 2017-02-11 08:26:31 | steven.daprano | set | nosy:
+ steven.daprano messages:
+ msg287595 |
| 2017-02-11 07:20:01 | naoyuki | create | |
