@@ -931,9 +931,9 @@ new_dict_with_shared_keys(PyInterpreterState *interp, PyDictKeysObject *keys)
931
931
size_t size = shared_keys_usable_size (keys );
932
932
PyDictValues * values = new_values (size );
933
933
if (values == NULL ) {
934
- dictkeys_decref (interp , keys , false);
935
934
return PyErr_NoMemory ();
936
935
}
936
+ dictkeys_incref (keys );
937
937
for (size_t i = 0 ; i < size ; i ++ ) {
938
938
values -> values [i ] = NULL ;
939
939
}
@@ -6666,8 +6666,6 @@ materialize_managed_dict_lock_held(PyObject *obj)
6666
6666
{
6667
6667
_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED (obj );
6668
6668
6669
- OBJECT_STAT_INC (dict_materialized_on_request );
6670
-
6671
6669
PyDictValues * values = _PyObject_InlineValues (obj );
6672
6670
PyInterpreterState * interp = _PyInterpreterState_GET ();
6673
6671
PyDictKeysObject * keys = CACHED_KEYS (Py_TYPE (obj ));
@@ -7178,8 +7176,6 @@ ensure_managed_dict(PyObject *obj)
7178
7176
goto done ;
7179
7177
}
7180
7178
#endif
7181
- OBJECT_STAT_INC (dict_materialized_on_request );
7182
- dictkeys_incref (CACHED_KEYS (tp ));
7183
7179
dict = (PyDictObject * )new_dict_with_shared_keys (_PyInterpreterState_GET (),
7184
7180
CACHED_KEYS (tp ));
7185
7181
FT_ATOMIC_STORE_PTR_RELEASE (_PyObject_ManagedDictPointer (obj )-> dict ,
@@ -7199,7 +7195,7 @@ ensure_nonmanaged_dict(PyObject *obj, PyObject **dictptr)
7199
7195
{
7200
7196
PyDictKeysObject * cached ;
7201
7197
7202
- PyObject * dict = FT_ATOMIC_LOAD_PTR_RELAXED (* dictptr );
7198
+ PyObject * dict = FT_ATOMIC_LOAD_PTR_ACQUIRE (* dictptr );
7203
7199
if (dict == NULL ) {
7204
7200
#ifdef Py_GIL_DISABLED
7205
7201
Py_BEGIN_CRITICAL_SECTION (obj );
@@ -7209,19 +7205,15 @@ ensure_nonmanaged_dict(PyObject *obj, PyObject **dictptr)
7209
7205
}
7210
7206
#endif
7211
7207
PyTypeObject * tp = Py_TYPE (obj );
7212
- if ((tp -> tp_flags & Py_TPFLAGS_HEAPTYPE ) && (cached = CACHED_KEYS (tp ))) {
7208
+ if (_PyType_HasFeature (tp , Py_TPFLAGS_HEAPTYPE ) && (cached = CACHED_KEYS (tp ))) {
7213
7209
PyInterpreterState * interp = _PyInterpreterState_GET ();
7214
7210
assert (!_PyType_HasFeature (tp , Py_TPFLAGS_INLINE_VALUES ));
7215
- dictkeys_incref (cached );
7216
7211
dict = new_dict_with_shared_keys (interp , cached );
7217
- if (dict == NULL ) {
7218
- dictkeys_decref (interp , cached , false);
7219
- }
7220
7212
}
7221
7213
else {
7222
7214
dict = PyDict_New ();
7223
7215
}
7224
- FT_ATOMIC_STORE_PTR_RELAXED (* dictptr , dict );
7216
+ FT_ATOMIC_STORE_PTR_RELEASE (* dictptr , dict );
7225
7217
#ifdef Py_GIL_DISABLED
7226
7218
done :
7227
7219
Py_END_CRITICAL_SECTION ();
@@ -7264,8 +7256,8 @@ _PyObjectDict_SetItem(PyTypeObject *tp, PyObject *obj, PyObject **dictptr,
7264
7256
7265
7257
Py_BEGIN_CRITICAL_SECTION (dict );
7266
7258
res = set_or_del_lock_held ((PyDictObject * )dict , key , value );
7267
- Py_END_CRITICAL_SECTION ();
7268
7259
ASSERT_CONSISTENT (dict );
7260
+ Py_END_CRITICAL_SECTION ();
7269
7261
return res ;
7270
7262
}
7271
7263
0 commit comments