8000 bpo-28994: PyErr_NormalizeException() no longer recursive. by serhiy-storchaka · Pull Request #2035 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

serhiy-storchaka
Copy link
Member
@serhiy-storchaka serhiy-storchaka commented Jun 9, 2017

@serhiy-storchaka serhiy-storchaka force-pushed the PyErr_NormalizeException-nonrecursive branch from 2f84b64 to 4dcbd8f Compare June 11, 2017 16:48
Python/errors.c Outdated
@@ -306,18 +313,17 @@ PyErr_NormalizeException(PyObject **exc, PyObject **val, PyObject **tb)
}
/* normalize recursively */
tstate = PyThreadState_GET();
if (++tstate->recursion_depth > Py_GetRecursionLimit()) {
--tstate->recursion_depth;
if (++recursion_depth > Py_GetRecursionLimit() - tstate->recursion_depth) {
Copy link
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
Member Author
8000

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.

Python/errors.c Outdated
@@ -306,18 +313,17 @@ PyErr_NormalizeException(PyObject **exc, PyObject **val, PyObject **tb)
}
/* normalize recursively */
Copy link
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:master Nov 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 free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0