Skip to content

Commit

Permalink
fixed error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
blhsing committed Jul 5, 2024
1 parent 4e1af59 commit 40f7c35
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Objects/frameobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2106,11 +2106,13 @@ PyObject*
_PyEval_BuiltinsFromGlobals(PyThreadState *tstate, PyObject *globals)
{
PyObject *builtins;
int has_builtins = PyMapping_GetOptionalItem(globals, &_Py_ID(__builtins__), &builtins);
int has_builtins = PyMapping_GetOptionalItem(
globals, &_Py_ID(__builtins__), &builtins);
if (has_builtins < 0) {
return NULL;
}
if (has_builtins) {
/* release reference right away since we mean to only borrow it */
Py_DECREF(builtins);
if (PyModule_Check(builtins)) {
builtins = _PyModule_GetDict(builtins);
Expand Down
3 changes: 2 additions & 1 deletion Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,8 @@ dummy_func(
int err = PyMapping_DelItem(GLOBALS(), name);
// Can't use ERROR_IF here.
if (err < 0) {
if (PyErr_ExceptionMatches(PyExc_KeyError)) {
if (_PyErr_Occurred(tstate) &&
_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) {
_PyEval_FormatExcCheckArg(tstate, PyExc_NameError,
NAME_ERROR_MSG, name);
}
Expand Down
3 changes: 2 additions & 1 deletion Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 40f7c35

Please sign in to comment.