diff options
author | Benjamin Peterson <benjamin@python.org> | 2010-11-17 22:33:12 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2010-11-17 22:33:12 (GMT) |
commit | f609654b0e36796275b7c9f822349e89fe9b4f2d (patch) | |
tree | be7d4cf8c94b36c9ea48bebd9589b4ca5e8e0954 /Lib/test/test_dict.py | |
parent | 12ae290bf32adbc8f4885ec342f5a17a4955fe15 (diff) | |
download | cpython-f609654b0e36796275b7c9f822349e89fe9b4f2d.zip cpython-f609654b0e36796275b7c9f822349e89fe9b4f2d.tar.gz cpython-f609654b0e36796275b7c9f822349e89fe9b4f2d.tar.bz2 |
handle dict subclasses gracefully in PyArg_ValidateKeywordArguments
Diffstat (limited to 'Lib/test/test_dict.py')
-rw-r--r-- | Lib/test/test_dict.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py index 818c99e..1507e42 100644 --- a/Lib/test/test_dict.py +++ b/Lib/test/test_dict.py @@ -8,10 +8,13 @@ import gc, weakref class DictTest(unittest.TestCase): def test_invalid_keyword_arguments(self): - with self.assertRaises(TypeError): - dict(**{1 : 2}) - with self.assertRaises(TypeError): - {}.update(**{1 : 2}) + class Custom(dict): + pass + for invalid in {1 : 2}, Custom({1 : 2}): + with self.assertRaises(TypeError): + dict(**invalid) + with self.assertRaises(TypeError): + {}.update(**invalid) def test_constructor(self): # calling built-in types without argument must return empty |