From 4e7a69bdb63a104587759d7784124492dcdd496e Mon Sep 17 00:00:00 2001 From: Mark Shannon Date: Wed, 2 Dec 2020 13:30:55 +0000 Subject: bpo-42500: Fix recursion in or after except (GH-23568) * Use counter, rather boolean state when handling soft overflows. --- Python/errors.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Python/errors.c') diff --git a/Python/errors.c b/Python/errors.c index f80ae21fdd..8242ac6978 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -290,12 +290,14 @@ _PyErr_NormalizeException(PyThreadState *tstate, PyObject **exc, PyObject **val, PyObject **tb) { int recursion_depth = 0; + tstate->recursion_headroom++; PyObject *type, *value, *initial_tb; restart: type = *exc; if (type == NULL) { /* There was no exception, so nothing to do. */ + tstate->recursion_headroom--; return; } @@ -347,6 +349,7 @@ _PyErr_NormalizeException(PyThreadState *tstate, PyObject **exc, } *exc = type; *val = value; + tstate->recursion_headroom--; return; error: -- cgit v1.2.1