mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-99300: Replace Py_INCREF() with Py_NewRef() (#99530)
Replace Py_INCREF() and Py_XINCREF() using a cast with Py_NewRef() and Py_XNewRef().
This commit is contained in:
parent
19c1462e8d
commit
8211cf5d28
18 changed files with 40 additions and 74 deletions
|
@ -1883,13 +1883,11 @@ _PyDict_SetItem_KnownHash(PyObject *op, PyObject *key, PyObject *value,
|
|||
assert(hash != -1);
|
||||
mp = (PyDictObject *)op;
|
||||
|
||||
Py_INCREF(key);
|
||||
Py_INCREF(value);
|
||||
if (mp->ma_keys == Py_EMPTY_KEYS) {
|
||||
return insert_to_emptydict(mp, key, hash, value);
|
||||
return insert_to_emptydict(mp, Py_NewRef(key), hash, Py_NewRef(value));
|
||||
}
|
||||
/* insertdict() handles any resizing that might be necessary */
|
||||
return insertdict(mp, key, hash, value);
|
||||
return insertdict(mp, Py_NewRef(key), hash, Py_NewRef(value));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2197,9 +2195,8 @@ _PyDict_Pop_KnownHash(PyObject *dict, PyObject *key, Py_hash_t hash, PyObject *d
|
|||
return NULL;
|
||||
}
|
||||
assert(old_value != NULL);
|
||||
Py_INCREF(old_value);
|
||||
uint64_t new_version = _PyDict_NotifyEvent(PyDict_EVENT_DELETED, mp, key, NULL);
|
||||
delitem_common(mp, hash, ix, old_value, new_version);
|
||||
delitem_common(mp, hash, ix, Py_NewRef(old_value), new_version);
|
||||
|
||||
ASSERT_CONSISTENT(mp);
|
||||
return old_value;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue