Skip to content

Commit c07191f

Browse files
committed
gh-145089: Fix frozendict constructor
1 parent fd01372 commit c07191f

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Lib/test/test_dict.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,6 +1736,16 @@ class FrozenDictSlots(frozendict):
17361736

17371737

17381738
class FrozenDictTests(unittest.TestCase):
1739+
def test_constructor(self):
1740+
# frozendict.__init__() has no effect
1741+
d = frozendict(a=1, b=2, c=3)
1742+
d.__init__(x=1)
1743+
self.assertEqual(d, frozendict(a=1, b=2, c=3))
1744+
1745+
# dict constructor cannot be used on frozendict
1746+
with self.assertRaises(TypeError):
1747+
dict.__init__(d, x=1)
1748+
17391749
def test_copy(self):
17401750
d = frozendict(x=1, y=2)
17411751
d2 = d.copy()

Objects/dictobject.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8143,7 +8143,6 @@ PyTypeObject PyFrozenDict_Type = {
81438143
.tp_richcompare = dict_richcompare,
81448144
.tp_iter = dict_iter,
81458145
.tp_methods = frozendict_methods,
8146-
.tp_init = dict_init,
81478146
.tp_alloc = _PyType_AllocNoTrack,
81488147
.tp_new = frozendict_new,
81498148
.tp_free = PyObject_GC_Del,

0 commit comments

Comments
 (0)