gh-141510: No longer accept frozendict in PyDict_Copy() (#145542) · python/cpython@0c29f83 · GitHub
Skip to content

Commit 0c29f83

Browse files
authored
gh-141510: No longer accept frozendict in PyDict_Copy() (#145542)
Rename _PyDict_Copy() to anydict_copy(). Replace PyObject_IsInstance(op, &PyFrozenDict_Type) with PyFrozenDict_Check().
1 parent dbe0007 commit 0c29f83

4 files changed

Lines changed: 66 additions & 38 deletions

File tree

Doc/c-api/dict.rst

Lines changed: 0 additions & 4 deletions

Lib/test/test_capi/test_dict.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,13 @@ def test_dictproxy_new(self):
9797
def test_dict_copy(self):
9898
# Test PyDict_Copy()
9999
copy = _testlimitedcapi.dict_copy
100-
for dict_type in ANYDICT_TYPES:
100+
for dict_type in DICT_TYPES:
101101
dct = dict_type({1: 2})
102102
dct_copy = copy(dct)
103-
if dict_type == frozendict:
104-
expected_type = frozendict
105-
self.assertIs(dct_copy, dct)
106-
else:
107-
if issubclass(dict_type, frozendict):
108-
expected_type = frozendict
109-
else:
110-
expected_type = dict
111-
self.assertIs(type(dct_copy), expected_type)
112-
self.assertEqual(dct_copy, dct)
103+
self.assertIs(type(dct_copy), dict)
104+
self.assertEqual(dct_copy, dct)
113105

114-
for test_type in NOT_ANYDICT_TYPES + OTHER_TYPES:
106+
for test_type in NOT_DICT_TYPES + OTHER_TYPES:
115107
self.assertRaises(SystemError, copy, test_type())
116108
self.assertRaises(SystemError, copy, NULL)
117109

Objects/clinic/dictobject.c.h

Lines changed: 19 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Objects/dictobject.c

Lines changed: 43 additions & 21 deletions

0 commit comments

Comments
 (0)