Skip to content

bpo-28994: PyErr_NormalizeException() no longer recursive. - #2035

Merged
serhiy-storchaka merged 4 commits into
python:masterfrom
serhiy-storchaka:PyErr_NormalizeException-nonrecursive
Nov 5, 2017
Merged

bpo-28994: PyErr_NormalizeException() no longer recursive.#2035
serhiy-storchaka merged 4 commits into
python:masterfrom
serhiy-storchaka:PyErr_NormalizeException-nonrecursive

Conversation

@serhiy-storchaka

@serhiy-storchakaserhiy-storchaka commented Jun 9, 2017

Copy link
Copy Markdown
Member

@serhiy-storchaka
serhiy-storchakaforce-pushed the PyErr_NormalizeException-nonrecursive branch from 2f84b64 to 4dcbd8fCompareJune 11, 2017 16:48
Comment threadPython/errors.c Outdated
tstate = PyThreadState_GET();
if (++tstate->recursion_depth > Py_GetRecursionLimit()) {
--tstate->recursion_depth;
if (++recursion_depth > Py_GetRecursionLimit() - tstate->recursion_depth) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the function isn't recursive anymore, is there any reason you're still bothering with recursion_depth?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A guard against infinite loop.

Comment threadPython/errors.c Outdated
@@ -306,18 +313,17 @@ PyErr_NormalizeException(PyObject **exc, PyObject **val, PyObject **tb)
}
/* normalize recursively */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this comment perhaps?

@serhiy-storchaka
serhiy-storchaka merged commit cf29653 into python:masterNov 5, 2017
@serhiy-storchaka
serhiy-storchaka deleted the PyErr_NormalizeException-nonrecursive branch November 5, 2017 09:27
embray pushed a commit to embray/cpython that referenced this pull request Nov 9, 2017
…sion. (python#2035)
MemoryError raised when normalizing a RecursionError raised during exception normalization now not always causes a fatal error.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip newstype-featureA feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@serhiy-storchaka@pitrou@the-knights-who-say-ni