-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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
bpo-28994: PyErr_NormalizeException() no longer recursive. #2035
Conversation
2f84b64
to
4dcbd8f
Compare
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) { |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update this comment perhaps?
…sion. (python#2035) MemoryError raised when normalizing a RecursionError raised during exception normalization now not always causes a fatal error.
https://bugs.python.org/issue28994