mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
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.
This commit is contained in:
parent
b962171414
commit
fb88636199
7 changed files with 57 additions and 2 deletions
|
|
@ -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(), {})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue