Skip to content
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

Avoid stack exhaustion in superclass_names() #175

Merged
merged 1 commit into from
Aug 6, 2021

Conversation

jparise
Copy link
Member

@jparise jparise commented Aug 4, 2021

Because this function is recursive, it can exhaust the stack if the
class hierarchy contains duplicate names. Avoid that using simple
memoization.

Also, these two supporting functions can be classmethods because they
don't use any instance-level state.

Fixes #174

@jparise jparise changed the title Revise superclass_names() Avoid recursion in superclass_names() Aug 4, 2021
@jparise jparise changed the title Avoid recursion in superclass_names() Avoid stack exhaustion in superclass_names() Aug 4, 2021
@sigmavirus24
Copy link
Member

Is it worth adding a test to show this doesn't break?

Because this function is recursive, it can exhaust the stack if the
class hierarchy contains duplicate names. Avoid that using simple
memoization.

Also, these two supporting functions can be classmethods because they
don't use any instance-level state.
@jparise
Copy link
Member Author

jparise commented Aug 5, 2021

Is it worth adding a test to show this doesn't break?

Yes, I had one locally that I forgot to include. It's there now.

@sigmavirus24 sigmavirus24 merged commit 37694a3 into PyCQA:master Aug 6, 2021
@jparise jparise deleted the superclass_names branch August 6, 2021 21:39
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.

RecursionError when checking class that inherits from same-named class
2 participants