Fix potential infinite recursion in __getattr__ #962
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I ran into an issue causing the infinite recursion, I saw that PR #912 was already open for it and the discussion that goes with it. But that PR hasn't changed in a while and didn't include a test for this bug.
I think this bug only happens for Python 3+ (I can at least confirm it with 3.7), when calling
copy
on aGithubCore
instance a call tofoo.__getattr__("_json_data")
is made while__init__
wasn't called. Causingself._json_data
here to call againself.__getattr__("_json_data")
and so on.By using
object.__getattribute__(self, "_json_data")
instead we make sure that we won't fallback on__getattr__
and avoid this infinite loop.