mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-112066: Use PyDict_SetDefaultRef
in place of PyDict_SetDefault
. (#112211)
This changes a number of internal usages of `PyDict_SetDefault` to use `PyDict_SetDefaultRef`. Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
This commit is contained in:
parent
fedbf77191
commit
ef3ceab09d
6 changed files with 32 additions and 25 deletions
|
@ -6683,7 +6683,7 @@ type_add_method(PyTypeObject *type, PyMethodDef *meth)
|
|||
int err;
|
||||
PyObject *dict = lookup_tp_dict(type);
|
||||
if (!(meth->ml_flags & METH_COEXIST)) {
|
||||
err = PyDict_SetDefault(dict, name, descr) == NULL;
|
||||
err = PyDict_SetDefaultRef(dict, name, descr, NULL) < 0;
|
||||
}
|
||||
else {
|
||||
err = PyDict_SetItem(dict, name, descr) < 0;
|
||||
|
@ -6731,7 +6731,7 @@ type_add_members(PyTypeObject *type)
|
|||
if (descr == NULL)
|
||||
return -1;
|
||||
|
||||
if (PyDict_SetDefault(dict, PyDescr_NAME(descr), descr) == NULL) {
|
||||
if (PyDict_SetDefaultRef(dict, PyDescr_NAME(descr), descr, NULL) < 0) {
|
||||
Py_DECREF(descr);
|
||||
return -1;
|
||||
}
|
||||
|
@ -6756,7 +6756,7 @@ type_add_getset(PyTypeObject *type)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (PyDict_SetDefault(dict, PyDescr_NAME(descr), descr) == NULL) {
|
||||
if (PyDict_SetDefaultRef(dict, PyDescr_NAME(descr), descr, NULL) < 0) {
|
||||
Py_DECREF(descr);
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue