diff options
author | Benjamin Peterson <benjamin@python.org> | 2010-04-24 18:21:17 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2010-04-24 18:21:17 (GMT) |
commit | fb88636199c12f63d6c8c89f311cdafc91f30d2f (patch) | |
tree | 24b2758c45ac543fe9970f861ca091852a8f4a94 /Lib/test/test_dict.py | |
parent | b962171414aa2cfe3dbfbd4294819a4153a7bd6c (diff) | |
download | cpython-fb88636199c12f63d6c8c89f311cdafc91f30d2f.zip cpython-fb88636199c12f63d6c8c89f311cdafc91f30d2f.tar.gz cpython-fb88636199c12f63d6c8c89f311cdafc91f30d2f.tar.bz2 |
prevent the dict constructor from accepting non-string keyword args #8419
This adds PyArg_ValidateKeywordArguments, which checks that keyword arguments
are all strings, using an optimized method if possible.
Diffstat (limited to 'Lib/test/test_dict.py')
-rw-r--r-- | Lib/test/test_dict.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py index 4ba0b71..6c5f682 100644 --- a/Lib/test/test_dict.py +++ b/Lib/test/test_dict.py @@ -7,6 +7,12 @@ 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}) + def test_constructor(self): # calling built-in types without argument must return empty self.assertEqual(dict(), {}) |