summaryrefslogtreecommitdiff
path: root/Lib/test/test_dict.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-10-31 14:05:55 -0400
committerBenjamin Peterson <benjamin@python.org>2012-10-31 14:05:55 -0400
commitd1f2cb37a2d1cc7b098abf6bc403fb5d43128051 (patch)
tree6474e4e081df0fe9f1ed4991835780f3443c9faa /Lib/test/test_dict.py
parentc43112823b1f748822c43ad42566537580c02af2 (diff)
downloadcpython-git-d1f2cb37a2d1cc7b098abf6bc403fb5d43128051.tar.gz
only fast-path fromkeys() when the constructor returns a empty dict (closes #16345)
Diffstat (limited to 'Lib/test/test_dict.py')
-rw-r--r--Lib/test/test_dict.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py
index d2740a3384..9666f9a31c 100644
--- a/Lib/test/test_dict.py
+++ b/Lib/test/test_dict.py
@@ -254,6 +254,14 @@ class DictTest(unittest.TestCase):
d = dict(zip(range(6), range(6)))
self.assertEqual(dict.fromkeys(d, 0), dict(zip(range(6), [0]*6)))
+ class baddict3(dict):
+ def __new__(cls):
+ return d
+ d = {i : i for i in range(10)}
+ res = d.copy()
+ res.update(a=None, b=None, c=None)
+ self.assertEqual(baddict3.fromkeys({"a", "b", "c"}), res)
+
def test_copy(self):
d = {1:1, 2:2, 3:3}
self.assertEqual(d.copy(), {1:1, 2:2, 3:3})