Issue #18408: ceval.c: in debug mode, convert the PyErr_Occurred() check on
exception (when getting NULL) to an assertion to detect bugs earlier
diff --git a/Python/ceval.c b/Python/ceval.c
index 8396f41..a53e377 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -3026,9 +3026,13 @@
         why = WHY_EXCEPTION;
 
         /* Double-check exception status. */
+#ifdef NDEBUG
         if (!PyErr_Occurred())
             PyErr_SetString(PyExc_SystemError,
                             "error return without exception set");
+#else
+        assert(PyErr_Occurred());
+#endif
 
         /* Log traceback info. */
         PyTraceBack_Here(f);