8000 Merge pull request #962 from smendes/fix-getattr · staticdev/github4.py@4443eeb · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on May 22, 2021. It is now read-only.

Commit 4443eeb

Browse files
authored
Merge pull request sigmavirus24#962 from smendes/fix-getattr
Fix potential infinite recursion in __getattr__
2 parents 9e749aa + 5509030 commit 4443eeb

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

AUTHORS.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,6 @@ Contributors
183183

184184
- Tigran Tchougourian (@NargiT)
185185

186-
- Dimitri Merejkowsky (@dmerejkowsky)
186+
- Samuel Mendes (@smendes)
187+
188+
- Dimitri Merejkowsky (@dmerejkowsky)

src/github3/models.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ def _update_attributes(self, json):
5454

5555
def __getattr__(self, attribute):
5656
"""Proxy access to stored JSON."""
57-
if attribute not in self._json_data:
57+
_json_data = object.__getattribute__(self, "_json_data")
58+
if attribute not in _json_data:
5859
raise AttributeError(attribute)
59-
value = self._json_data.get(attribute)
60+
value = _json_data[attribute]
6061
setattr(self, attribute, value)
6162
return value
6263

tests/unit/test_models.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import pytest
44
import requests
55

6+
from copy import copy
67
from datetime import datetime, timedelta
78
from github3 import exceptions, GitHubError
89
from github3.models import GitHubCore
@@ -206,6 +207,10 @@ def test_strptime_time_str_required(self):
206207
"""Verify that method converts ISO 8601 formatted string."""
207208
assert self.instance._strptime("") is None
208209

210+
def test_can_be_copied(self):
211+
"""Verify that a GithubCore object can be copied."""
212+
assert copy(self.instance) is not None
213+
209214

210215
class TestGitHubCoreIssue672(helper.UnitHelper):
211216

0 commit comments

Comments
 (0)
0