Skip to content

Commit 395fd9c

Browse files
gh-111789: Use PyDict_GetItemRef() in Python/bltinmodule.c (gh-112081)
1 parent d890893 commit 395fd9c

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Python/bltinmodule.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "pycore_call.h" // _PyObject_CallNoArgs()
66
#include "pycore_ceval.h" // _PyEval_Vector()
77
#include "pycore_compile.h" // _PyAST_Compile()
8-
#include "pycore_dict.h" // _PyDict_GetItemWithError()
98
#include "pycore_long.h" // _PyLong_CompactValue
109
#include "pycore_modsupport.h" // _PyArg_NoKwnames()
1110
#include "pycore_object.h" // _Py_AddToAllObjects()
@@ -141,18 +140,16 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs,
141140
goto error;
142141
}
143142

144-
meta = _PyDict_GetItemWithError(mkw, &_Py_ID(metaclass));
143+
if (PyDict_GetItemRef(mkw, &_Py_ID(metaclass), &meta) < 0) {
144+
goto error;
145+
}
145146
if (meta != NULL) {
146-
Py_INCREF(meta);
147147
if (PyDict_DelItem(mkw, &_Py_ID(metaclass)) < 0) {
148148
goto error;
149149
}
150150
/* metaclass is explicitly given, check if it's indeed a class */
151151
isclass = PyType_Check(meta);
152152
}
153-
else if (PyErr_Occurred()) {
154-
goto error;
155-
}
156153
}
157154
if (meta == NULL) {
158155
/* if there are no bases, use type: */

0 commit comments

Comments
 (0)