Issue 24017: fix for "async with" refcounting
* adds missing INCREF in WITH_CLEANUP_START
* adds missing DECREF in WITH_CLEANUP_FINISH
* adds several new tests Yury created while investigating this
diff --git a/Python/ceval.c b/Python/ceval.c
index 77085c2..afb0f89 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -3156,6 +3156,7 @@
if (res == NULL)
goto error;
+ Py_INCREF(exc); /* Duplicating the exception on the stack */
PUSH(exc);
PUSH(res);
PREDICT(WITH_CLEANUP_FINISH);
@@ -3174,6 +3175,7 @@
err = 0;
Py_DECREF(res);
+ Py_DECREF(exc);
if (err < 0)
goto error;