Skip to content

Define RecursionError for Python versions < 3.5 #10422

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

Merged
merged 1 commit into from
Feb 13, 2018

Conversation

cclauss
Copy link

@cclauss cclauss commented Feb 11, 2018

RecursionError is used on line 189. https://docs.python.org/3/library/exceptions.html#RecursionError

PR Summary

Fixes undefined name RecursionError in Python versions < 3.5.

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@jklymak
Copy link
Member

jklymak commented Feb 11, 2018

We test in 3.4. So either this code is ignored in that test or it works pre 3.5

@cclauss
Copy link
Author

cclauss commented Feb 11, 2018

Does the testing raise an exception? Is the exception raised a NameError or a RecursionError or a RuntimeError?

@tacaswell tacaswell added this to the v2.2 milestone Feb 11, 2018
@tacaswell
Copy link
Member

The failure is from master branch, not this PR.

It looks like the exception is used at the bottom to get a nicer print when a particular failure happened so in the normal case we never exercise the 'except' branch. This is fine, but might be better to remove the try block where the exception is used

def test_rrulewrapper():
r = rrulewrapper(2)
try:
pickle.loads(pickle.dumps(r))
except RecursionError:
print('rrulewrapper pickling test failed')
raise

@tacaswell
Copy link
Member

Thanks for finding and fixing all of these issues @cclauss !

@QuLogic
Copy link
Member

QuLogic commented Feb 11, 2018

@jklymak Yep, if it never raises, then the wrong name isn't a problem:

>>> try:
...     1
... except NotARealExceptionError:
...     pass
... 
1

vs.

>>> try:
...     a
... except NotARealExceptionError:
...     pass
... 
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
NameError: name 'a' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
NameError: name 'NotARealExceptionError' is not defined

@anntzer anntzer modified the milestones: needs sorting, v2.2.1 Feb 13, 2018
@anntzer anntzer merged commit 0c3b9d7 into matplotlib:master Feb 13, 2018
@cclauss cclauss deleted the patch-1 branch February 13, 2018 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants