bpo-29532: Altering a kwarg dictionary passed to functools.partial() no longer affects a partial object after creation. (#209)
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
index 824549b..b7d648d 100644
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -89,6 +89,15 @@
p(b=7)
self.assertEqual(d, {'a':3})
+ def test_kwargs_copy(self):
+ # Issue #29532: Altering a kwarg dictionary passed to a constructor
+ # should not affect a partial object after creation
+ d = {'a': 3}
+ p = self.partial(capture, **d)
+ self.assertEqual(p(), ((), {'a': 3}))
+ d['a'] = 5
+ self.assertEqual(p(), ((), {'a': 3}))
+
def test_arg_combinations(self):
# exercise special code paths for zero args in either partial
# object or the caller