Skip to content

Commit 1cfa0ba

Browse files
committed
Fix macro expansion of _PyErr_OCCURRED(), and make sure to use it in at least one place so as to avoid regressions.
2 parents 648f860 + 59c900d commit 1cfa0ba

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎Include/pyerrors.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ PyAPI_FUNC(void) Py_FatalError(const char *message) _Py_NO_RETURN;
101101
#if defined(Py_DEBUG) || defined(Py_LIMITED_API)
102102
#define _PyErr_OCCURRED() PyErr_Occurred()
103103
#else
104-
#define _PyErr_OCCURRED() (_PyThreadState_Current->curexc_type)
104+
#define _PyErr_OCCURRED() (PyThreadState_GET()->curexc_type)
105105
#endif
106106

107107
/* Error testing and normalization */

‎Misc/NEWS‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Projected release date: 2013-10-20
1010
Core and Builtins
1111
-----------------
1212

13+
- Fix macro expansion of _PyErr_OCCURRED(), and make sure to use it in at
14+
least one place so as to avoid regressions.
15+
1316
- Issue #19087: Improve bytearray allocation in order to allow cheap popping
1417
of data at the front (slice deletion).
1518

‎Python/ceval.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2162,7 +2162,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
21622162
}
21632163
else {
21642164
v = PyObject_GetItem(locals, name);
2165-
if (v == NULL && PyErr_Occurred()) {
2165+
if (v == NULL && _PyErr_OCCURRED()) {
21662166
if (!PyErr_ExceptionMatches(PyExc_KeyError))
21672167
goto error;
21682168
PyErr_Clear();
@@ -2207,7 +2207,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
22072207
(PyDictObject *)f->f_builtins,
22082208
name);
22092209
if (v == NULL) {
2210-
if (!PyErr_Occurred())
2210+
if (!_PyErr_OCCURRED())
22112211
format_exc_check_arg(PyExc_NameError,
22122212
NAME_ERROR_MSG, name);
22132213
goto error;

0 commit comments

Comments
 (0)