diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2023-11-27 17:52:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-27 17:52:54 (GMT) |
commit | 395fd9c1808fa0babc96540744d2c915178a452b (patch) | |
tree | 09fadc8c336e1e33def8d01ac79c0e57c88dbec4 | |
parent | d8908932fc03e064ba8df03d17d8cc7ffa5f171f (diff) | |
download | cpython-395fd9c1808fa0babc96540744d2c915178a452b.zip cpython-395fd9c1808fa0babc96540744d2c915178a452b.tar.gz cpython-395fd9c1808fa0babc96540744d2c915178a452b.tar.bz2 |
gh-111789: Use PyDict_GetItemRef() in Python/bltinmodule.c (gh-112081)
-rw-r--r-- | Python/bltinmodule.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index ff07c49..7a96251 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -5,7 +5,6 @@ #include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_ceval.h" // _PyEval_Vector() #include "pycore_compile.h" // _PyAST_Compile() -#include "pycore_dict.h" // _PyDict_GetItemWithError() #include "pycore_long.h" // _PyLong_CompactValue #include "pycore_modsupport.h" // _PyArg_NoKwnames() #include "pycore_object.h" // _Py_AddToAllObjects() @@ -141,18 +140,16 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs, goto error; } - meta = _PyDict_GetItemWithError(mkw, &_Py_ID(metaclass)); + if (PyDict_GetItemRef(mkw, &_Py_ID(metaclass), &meta) < 0) { + goto error; + } if (meta != NULL) { - Py_INCREF(meta); if (PyDict_DelItem(mkw, &_Py_ID(metaclass)) < 0) { goto error; } /* metaclass is explicitly given, check if it's indeed a class */ isclass = PyType_Check(meta); } - else if (PyErr_Occurred()) { - goto error; - } } if (meta == NULL) { /* if there are no bases, use type: */ |