summaryrefslogtreecommitdiffstats
path: root/Objects/dictobject.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-11-16 17:34:24 (GMT)
committerGitHub <noreply@github.com>2022-11-16 17:34:24 (GMT)
commit8211cf5d287acfd815b6a7f6471cdf83dcd2bb9b (patch)
tree510409237622aa30dfc6833602bdde97c578f2bb /Objects/dictobject.c
parent19c1462e8dca3319c8290e2edcce482bd18cb018 (diff)
downloadcpython-8211cf5d287acfd815b6a7f6471cdf83dcd2bb9b.zip
cpython-8211cf5d287acfd815b6a7f6471cdf83dcd2bb9b.tar.gz
cpython-8211cf5d287acfd815b6a7f6471cdf83dcd2bb9b.tar.bz2
gh-99300: Replace Py_INCREF() with Py_NewRef() (#99530)
Replace Py_INCREF() and Py_XINCREF() using a cast with Py_NewRef() and Py_XNewRef().
Diffstat (limited to 'Objects/dictobject.c')
-rw-r--r--Objects/dictobject.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index fc48720..51903ab 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -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;