diff options
author | Benjamin Peterson <benjamin@python.org> | 2012-10-31 14:05:55 -0400 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2012-10-31 14:05:55 -0400 |
commit | d1f2cb37a2d1cc7b098abf6bc403fb5d43128051 (patch) | |
tree | 6474e4e081df0fe9f1ed4991835780f3443c9faa /Lib/test/test_dict.py | |
parent | c43112823b1f748822c43ad42566537580c02af2 (diff) | |
download | cpython-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.py | 8 |
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}) |