-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Add a dedicated subclass for recursion errors #63434
Comments
There's no dedicated StackOverflowErrorException, So there is no way to accurately distinguish a recursion overflow from a general RuntimeError. One cannot use the exception message, since the docs explicitly says that "Exception messages are not part of the Python API", and checking for
is ugly, and (AFAIK) not guaranteed to be correct. Use case: I've found this while trying to create a cycle detector that will compress the traceback of such errors. See discussion in python-ideas: An cycle-detection implementation: |
This sounds like a reasonable feature request to me. |
I agree. |
Attached is a patch, please review. Introduces a RecursionError that subclasses RuntimeError for compatibility. Note: I also tested this with RecursionError not subclassing RuntimeError, to make sure that except clauses in the test suite are sufficiently narrowed to RecursionError. |
Looks good to me. Is it possible to add it to 2.7? I think it won't break any PEP-8-following code (e.g. not testing for type equality/identity) |
+1 |
Is it going to be committed? |
It's an enhancement, so it can only go in 3.5, and that will happen some time after the release of 3.4. |
Ok |
So what holds it back now? |
+1. This, unfortunately, can't go in 3.5 (too late), but I can commit this in 3.6. |
Well that's a déjà vu. |
Larry, is there any chance this can be committed in 3.5 (the change is fully backwards compatible)? |
This is fine for 3.5. |
New changeset a795cf73ce6f by Yury Selivanov in branch '3.5': New changeset 749d74e5dfa7 by Yury Selivanov in branch 'default': |
Thanks Larry and Georg! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: