diff options
author | Mark Shannon <mark@hotpy.org> | 2021-03-02 10:36:38 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-02 11:36:38 +0100 |
commit | 8b795ab5541d8a4e69be4137dfdc207714270b77 (patch) | |
tree | d7fcc96f3243d082ea024964a643a32a004a5fbd /Python/errors.c | |
parent | f836e5f2194857b24ec03adfcfcce05375868f88 (diff) | |
download | cpython-git-8b795ab5541d8a4e69be4137dfdc207714270b77.tar.gz |
bpo-42500: Fix recursion in or after except (GH-23568) (#24501)
* Use counter, rather boolean state when handling soft overflows.
(cherry picked from commit 4e7a69bdb63a104587759d7784124492dcdd496e)
Diffstat (limited to 'Python/errors.c')
-rw-r--r-- | Python/errors.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Python/errors.c b/Python/errors.c index 87af39d527..d8c2d8b923 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: |