diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py index 14b501360d0b8e..8a4e19c95a36ef 100644 --- a/Lib/test/test_dict.py +++ b/Lib/test/test_dict.py @@ -1736,6 +1736,16 @@ class FrozenDictSlots(frozendict): class FrozenDictTests(unittest.TestCase): + def test_constructor(self): + # frozendict.__init__() has no effect + d = frozendict(a=1, b=2, c=3) + d.__init__(x=1) + self.assertEqual(d, frozendict(a=1, b=2, c=3)) + + # dict constructor cannot be used on frozendict + with self.assertRaises(TypeError): + dict.__init__(d, x=1) + def test_copy(self): d = frozendict(x=1, y=2) d2 = d.copy() diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 6c802ca569d48c..35ca9933bfa8ae 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -8143,7 +8143,6 @@ PyTypeObject PyFrozenDict_Type = { .tp_richcompare = dict_richcompare, .tp_iter = dict_iter, .tp_methods = frozendict_methods, - .tp_init = dict_init, .tp_alloc = _PyType_AllocNoTrack, .tp_new = frozendict_new, .tp_free = PyObject_GC_Del,