From: Serhiy Storchaka Date: Mon, 27 Nov 2023 17:51:31 +0000 (+0200) Subject: gh-111789: Use PyDict_GetItemRef() in Modules/pyexpat.c (gh-112079) X-Git-Tag: v3.13.0a3~624 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d8908932fc03e064ba8df03d17d8cc7ffa5f171f;p=thirdparty%2FPython%2Fcpython.git gh-111789: Use PyDict_GetItemRef() in Modules/pyexpat.c (gh-112079) --- diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index 21579a80dd7f..9d95309dbb7a 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -240,19 +240,12 @@ string_intern(xmlparseobject *self, const char* str) return result; if (!self->intern) return result; - value = PyDict_GetItemWithError(self->intern, result); - if (!value) { - if (!PyErr_Occurred() && - PyDict_SetItem(self->intern, result, result) == 0) - { - return result; - } - else { - Py_DECREF(result); - return NULL; - } + if (PyDict_GetItemRef(self->intern, result, &value) == 0 && + PyDict_SetItem(self->intern, result, result) == 0) + { + return result; } - Py_INCREF(value); + assert((value != NULL) == !PyErr_Occurred()); Py_DECREF(result); return value; }