Skip to content

Commit a486054

Browse files
authored
bpo-43270: Remove private _PyErr_OCCURRED() macro (pythonGH-24579)
Remove the private _PyErr_OCCURRED() macro: use the public PyErr_Occurred() function instead. CPython internals must use the internal _PyErr_Occurred(tstate) function instead: it is the most efficient way to check if an exception was raised.
1 parent acde3f1 commit a486054

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

Include/pyerrors.h

-6
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ PyAPI_FUNC(void) PyErr_SetExcInfo(PyObject *, PyObject *, PyObject *);
3030
macro is defined. */
3131
PyAPI_FUNC(void) _Py_NO_RETURN Py_FatalError(const char *message);
3232

33-
#if defined(Py_DEBUG) || defined(Py_LIMITED_API)
34-
#define _PyErr_OCCURRED() PyErr_Occurred()
35-
#else
36-
#define _PyErr_OCCURRED() (PyThreadState_GET()->curexc_type)
37-
#endif
38-
3933
/* Error testing and normalization */
4034
PyAPI_FUNC(int) PyErr_GivenExceptionMatches(PyObject *, PyObject *);
4135
PyAPI_FUNC(int) PyErr_ExceptionMatches(PyObject *);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Remove the private ``_PyErr_OCCURRED()`` macro: use the public
2+
:c:func:`PyErr_Occurred` function instead.

Python/ceval.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2750,7 +2750,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
27502750
(PyDictObject *)f->f_builtins,
27512751
name);
27522752
if (v == NULL) {
2753-
if (!_PyErr_OCCURRED()) {
2753+
if (!_PyErr_Occurred(tstate)) {
27542754
/* _PyDict_LoadGlobal() returns NULL without raising
27552755
* an exception if the key doesn't exist */
27562756
format_exc_check_arg(tstate, PyExc_NameError,

0 commit comments

Comments
 (0)