diff options
author | Benjamin Peterson <benjamin@python.org> | 2012-10-31 18:05:55 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2012-10-31 18:05:55 (GMT) |
commit | 0ec820fc5fbefe2fd49915fb640166644a4cdb8e (patch) | |
tree | d2d422011523f2207de79f50c2e070341a71f6a8 /Lib/test | |
parent | bdf1b9e26754de09883321c181bed7ddbc513ab8 (diff) | |
download | cpython-0ec820fc5fbefe2fd49915fb640166644a4cdb8e.zip cpython-0ec820fc5fbefe2fd49915fb640166644a4cdb8e.tar.gz cpython-0ec820fc5fbefe2fd49915fb640166644a4cdb8e.tar.bz2 |
only fast-path fromkeys() when the constructor returns a empty dict (closes #16345)
Diffstat (limited to 'Lib/test')
-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 18f7ce6..0840f59 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}) |