8000 Fix potential infinite recursion in __getattr__ · staticdev/github4.py@00c2f9c · 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 00c2f9c

Browse files
committed
Fix potential infinite recursion in __getattr__
1 parent 043d61f commit 00c2f9c

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
@@ -181,4 +181,6 @@ Contributors
181181

182182
- Steven Nyman (@stevennyman)
183183

184-
- Tigran Tchougourian (@NargiT)
184+
- Tigran Tchougourian (@NargiT)
185+
186+
- Samuel Mendes (@smendes)

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