mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03: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
|
|
@ -691,11 +691,10 @@ _parse_object_unicode(PyScannerObject *s, PyObject *memo, PyObject *pystr, Py_ss
|
|||
key = scanstring_unicode(pystr, idx + 1, s->strict, &next_idx);
|
||||
if (key == NULL)
|
||||
goto bail;
|
||||
memokey = PyDict_SetDefault(memo, key, key);
|
||||
if (memokey == NULL) {
|
||||
if (PyDict_SetDefaultRef(memo, key, key, &memokey) < 0) {
|
||||
goto bail;
|
||||
}
|
||||
Py_SETREF(key, Py_NewRef(memokey));
|
||||
Py_SETREF(key, memokey);
|
||||
idx = next_idx;
|
||||
|
||||
/* skip whitespace between key and : delimiter, read :, skip whitespace */
|
||||
|
|
|
|||
|
|
@ -1627,7 +1627,7 @@ convertenviron(void)
|
|||
Py_DECREF(d);
|
||||
return NULL;
|
||||
}
|
||||
if (PyDict_SetDefault(d, k, v) == NULL) {
|
||||
if (PyDict_SetDefaultRef(d, k, v, NULL) < 0) {
|
||||
Py_DECREF(v);
|
||||
Py_DECREF(k);
|
||||
Py_DECREF(d);
|
||||
|
|
|
|||
|
|
@ -1615,7 +1615,8 @@ static int init_handler_descrs(pyexpat_state *state)
|
|||
if (descr == NULL)
|
||||
return -1;
|
||||
|
||||
if (PyDict_SetDefault(state->xml_parse_type->tp_dict, PyDescr_NAME(descr), descr) == NULL) {
|
||||
if (PyDict_SetDefaultRef(state->xml_parse_type->tp_dict,
|
||||
PyDescr_NAME(descr), descr, NULL) < 0) {
|
||||
Py_DECREF(descr);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue