8000 Fix potential infinite recursion in __getattr__ by smendes · Pull Request #962 · sigmavirus24/github3.py · GitHub
[go: up one dir, main page]

Skip to content

Fix potential infinite recursion in __getattr__ #962

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 2 commits into from
Jul 30, 2019

Conversation

smendes
Copy link
Contributor
@smendes smendes commented Jul 23, 2019

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 a GithubCore instance a call to foo.__getattr__("_json_data") is made while __init__ wasn't called. Causing self._json_data here to call again self.__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.

Copy link
Contributor
@dprothero dprothero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sigmavirus24 sigmavirus24 merged commit 4443eeb into sigmavirus24:master Jul 30, 2019
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.

3 participants
0