Permalink
Browse files

Avoid triggering fetch for all hidden attributes

  • Loading branch information...
bboe committed Nov 27, 2016
1 parent 9ac8bc6 commit 280525c16ba28cdd69cdbb272a0e2764b1c7e6a0
Showing with 15 additions and 1 deletion.
  1. +8 −0 CHANGES.rst
  2. +1 −1 praw/models/reddit/base.py
  3. +6 −0 tests/unit/models/reddit/test_comment.py
@@ -1,6 +1,14 @@
Change Log
==========
Unreleased
----------
**Fixed**
* Fix bug where ipython tries to access attribute
``_ipython_canary_method_should_not_exist_`` resulting in a useless fetch.
4.0.0rc3 (2016/11/26)
---------------------
@@ -27,7 +27,7 @@ def __eq__(self, other):
def __getattr__(self, attribute):
"""Return the value of `attrribute`."""
if not attribute.startswith('__') and not self._fetched:
if not attribute.startswith('_') and not self._fetched:
self._fetch()
return getattr(self, attribute)
raise AttributeError('{!r} object has no attribute {!r}'
@@ -54,3 +54,9 @@ def test_repr(self):
def test_str(self):
comment = Comment(self.reddit, _data={'id': 'dummy'})
assert str(comment) == 'dummy'
def test_unset_hidden_attribute_does_not_fetch(self):
comment = Comment(self.reddit, _data={'id': 'dummy'})
with pytest.raises(AttributeError):
comment._ipython_canary_method_should_not_exist_
assert not comment._fetched

0 comments on commit 280525c

Please sign in to comment.