@@ -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
}
@@ -6693,8 +6693,6 @@ materialize_managed_dict_lock_held(PyObject *obj)
6693
6693
{
6694
6694
_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED (obj );
6695
6695
6696
- OBJECT_STAT_INC (dict_materialized_on_request );
6697
-
6698
6696
PyDictValues * values = _PyObject_InlineValues (obj );
6699
6697
PyInterpreterState * interp = _PyInterpreterState_GET ();
6700
6698
PyDictKeysObject * keys = CACHED_KEYS (Py_TYPE (obj ));
@@ -7205,8 +7203,6 @@ ensure_managed_dict(PyObject *obj)
7205
7203
goto done ;
7206
7204
}
7207
7205
#endif
7208
- OBJECT_STAT_INC (dict_materialized_on_request );
7209
- dictkeys_incref (CACHED_KEYS (tp ));
7210
7206
dict = (PyDictObject * )new_dict_with_shared_keys (_PyInterpreterState_GET (),
7211
7207
CACHED_KEYS (tp ));
7212
7208
FT_ATOMIC_STORE_PTR_RELEASE (_PyObject_ManagedDictPointer (obj )-> dict ,
@@ -7226,7 +7222,7 @@ ensure_nonmanaged_dict(PyObject *obj, PyObject **dictptr)
7226
7222
{
7227
7223
PyDictKeysObject * cached ;
7228
7224
7229
- PyObject * dict = FT_ATOMIC_LOAD_PTR_RELAXED (* dictptr );
7225
+ PyObject * dict = FT_ATOMIC_LOAD_PTR_ACQUIRE (* dictptr );
7230
7226
if (dict == NULL ) {
7231
7227
#ifdef Py_GIL_DISABLED
7232
7228
Py_BEGIN_CRITICAL_SECTION (obj );
@@ -7236,19 +7232,15 @@ ensure_nonmanaged_dict(PyObject *obj, PyObject **dictptr)
7236
7232
}
7237
7233
#endif
7238
7234
PyTypeObject * tp = Py_TYPE (obj );
7239
- if ((tp -> tp_flags & Py_TPFLAGS_HEAPTYPE ) && (cached = CACHED_KEYS (tp ))) {
7235
+ if (_PyType_HasFeature (tp , Py_TPFLAGS_HEAPTYPE ) && (cached = CACHED_KEYS (tp ))) {
7240
7236
PyInterpreterState * interp = _PyInterpreterState_GET ();
7241
7237
assert (!_PyType_HasFeature (tp , Py_TPFLAGS_INLINE_VALUES ));
7242
- dictkeys_incref (cached );
7243
7238
dict = new_dict_with_shared_keys (interp , cached );
7244
- if (dict == NULL ) {
7245
- dictkeys_decref (interp , cached , false);
7246
- }
7247
7239
}
7248
7240
else {
7249
7241
dict = PyDict_New ();
7250
7242
}
7251
- FT_ATOMIC_STORE_PTR_RELAXED (* dictptr , dict );
7243
+ FT_ATOMIC_STORE_PTR_RELEASE (* dictptr , dict );
7252
7244
#ifdef Py_GIL_DISABLED
7253
7245
done :
7254
7246
Py_END_CRITICAL_SECTION ();
0 commit comments