summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Python/ceval.c
diff options
context:
space:
mode:
authorAlexSm <[email protected]>2024-02-12 10:25:32 +0100
committerGitHub <[email protected]>2024-02-12 10:25:32 +0100
commit12610a7bf38a4f1215aeb6eeea5e27e271c17e50 (patch)
treefce5b3816c5d68d91d7f1f6617c65b04e92f79a9 /contrib/tools/python3/src/Python/ceval.c
parentb314cf4cbae67afc30e1f9c2f14047de0ad996cb (diff)
parent6a0655781d6103303eed0d377c3fb0955e468b5b (diff)
Merge pull request #1777 from alexv-smirnov/mergelibs13
Library import 13
Diffstat (limited to 'contrib/tools/python3/src/Python/ceval.c')
-rw-r--r--contrib/tools/python3/src/Python/ceval.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/contrib/tools/python3/src/Python/ceval.c b/contrib/tools/python3/src/Python/ceval.c
index bb6bb35030d..1ce6bbc10fb 100644
--- a/contrib/tools/python3/src/Python/ceval.c
+++ b/contrib/tools/python3/src/Python/ceval.c
@@ -7153,11 +7153,8 @@ PyObject *
_PyEval_GetBuiltin(PyObject *name)
{
PyThreadState *tstate = _PyThreadState_GET();
- PyObject *attr = PyDict_GetItemWithError(PyEval_GetBuiltins(), name);
- if (attr) {
- Py_INCREF(attr);
- }
- else if (!_PyErr_Occurred(tstate)) {
+ PyObject *attr = PyObject_GetItem(PyEval_GetBuiltins(), name);
+ if (attr == NULL && _PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
_PyErr_SetObject(tstate, PyExc_AttributeError, name);
}
return attr;
@@ -7407,9 +7404,9 @@ import_name(PyThreadState *tstate, _PyInterpreterFrame *frame,
PyObject *import_func, *res;
PyObject* stack[5];
- import_func = _PyDict_GetItemWithError(frame->f_builtins, &_Py_ID(__import__));
+ import_func = PyObject_GetItem(frame->f_builtins, &_Py_ID(__import__));
if (import_func == NULL) {
- if (!_PyErr_Occurred(tstate)) {
+ if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
_PyErr_SetString(tstate, PyExc_ImportError, "__import__ not found");
}
return NULL;
@@ -7417,6 +7414,7 @@ import_name(PyThreadState *tstate, _PyInterpreterFrame *frame,
PyObject *locals = frame->f_locals;
/* Fast path for not overloaded __import__. */
if (import_func == tstate->interp->import_func) {
+ Py_DECREF(import_func);
int ilevel = _PyLong_AsInt(level);
if (ilevel == -1 && _PyErr_Occurred(tstate)) {
return NULL;
@@ -7430,8 +7428,6 @@ import_name(PyThreadState *tstate, _PyInterpreterFrame *frame,
return res;
}
- Py_INCREF(import_func);
-
stack[0] = name;
stack[1] = frame->f_globals;
stack[2] = locals == NULL ? Py_None : locals;