mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
handle dict subclasses gracefully in PyArg_ValidateKeywordArguments
This commit is contained in:
parent
12ae290bf3
commit
f609654b0e
4 changed files with 14 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue