]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-141510: Update mp_length of frozendict to use non atomic operation (gh-144913)
authorDonghee Na <donghee.na@python.org>
Tue, 17 Feb 2026 13:39:56 +0000 (22:39 +0900)
committerGitHub <noreply@github.com>
Tue, 17 Feb 2026 13:39:56 +0000 (13:39 +0000)
Objects/dictobject.c

index 46b0148cf59ab592780c8bbbcc8aa58c2ae0bc8e..510a0fab468cc60c814fd3e15de55d9c16f1d438 100644 (file)
@@ -3482,6 +3482,12 @@ dict_length(PyObject *self)
     return GET_USED(_PyAnyDict_CAST(self));
 }
 
+static Py_ssize_t
+frozendict_length(PyObject *self)
+{
+    return _PyAnyDict_CAST(self)->ma_used;
+}
+
 static PyObject *
 dict_subscript(PyObject *self, PyObject *key)
 {
@@ -7833,7 +7839,7 @@ static PyNumberMethods frozendict_as_number = {
 };
 
 static PyMappingMethods frozendict_as_mapping = {
-    .mp_length = dict_length,
+    .mp_length = frozendict_length,
     .mp_subscript = dict_subscript,
 };