1. mirror
  2. cpython

Commits

Antoine Pitrou  committed 2aee9c4

Fix macro expansion of _PyErr_OCCURRED(), and make sure to use it in at least one place so as to avoid regressions.

  • Participants
  • Parent commits b4444d1
  • Branches 3.3

Comments (0)

Files changed (3)

File Include/pyerrors.h

View file
 #if defined(Py_DEBUG) || defined(Py_LIMITED_API)
 #define _PyErr_OCCURRED() PyErr_Occurred()
 #else
-#define _PyErr_OCCURRED() (_PyThreadState_Current->curexc_type)
+#define _PyErr_OCCURRED() (PyThreadState_GET()->curexc_type)
 #endif
 
 /* Error testing and normalization */

File Misc/NEWS

View file
 Core and Builtins
 -----------------
 
+- Fix macro expansion of _PyErr_OCCURRED(), and make sure to use it in at
+  least one place so as to avoid regressions.
+
 - Issue #19014: memoryview.cast() is now allowed on zero-length views.
 
 - Issue #19098: Prevent overflow in the compiler when the recursion limit is set

File Python/ceval.c

View file
             }
             else {
                 x = PyObject_GetItem(v, w);
-                if (x == NULL && PyErr_Occurred()) {
+                if (x == NULL && _PyErr_OCCURRED()) {
                     if (!PyErr_ExceptionMatches(
                                     PyExc_KeyError))
                         break;
                                        (PyDictObject *)f->f_builtins,
                                        w);
                 if (x == NULL) {
-                    if (!PyErr_Occurred())
+                    if (!_PyErr_OCCURRED())
                         format_exc_check_arg(PyExc_NameError,
                                              GLOBAL_NAME_ERROR_MSG, w);
                     break;