diff --git a/_pytest/assertion/oldinterpret.py b/_pytest/assertion/oldinterpret.py index 40c6d3936..8ca1d8f5c 100644 --- a/_pytest/assertion/oldinterpret.py +++ b/_pytest/assertion/oldinterpret.py @@ -57,7 +57,7 @@ class View(object): def __getattr__(self, attr): # attributes not found in the normal hierarchy rooted on View # are looked up in the object's real class - return getattr(self.__obj__, attr) + return getattr(object.__getattribute__(self, '__obj__'), attr) def __viewkey__(self): return self.__obj__.__class__ diff --git a/_pytest/capture.py b/_pytest/capture.py index 1f4762b06..c22c34bad 100644 --- a/_pytest/capture.py +++ b/_pytest/capture.py @@ -238,10 +238,7 @@ class EncodedFile(object): self.write(data) def __getattr__(self, name): - if hasattr(self, "buffer"): - return getattr(self.buffer, name) - else: - raise AttributeError("attribute buffer of %r not set" % self) + return getattr(object.__getattribute__(self, "buffer"), name) class MultiCapture(object): diff --git a/_pytest/main.py b/_pytest/main.py index 1be074243..2d46c56e8 100644 --- a/_pytest/main.py +++ b/_pytest/main.py @@ -153,15 +153,14 @@ def pytest_ignore_collect(path, config): ignore_paths.extend([py.path.local(x) for x in excludeopt]) return path in ignore_paths -class HookProxy: +class HookProxy(object): def __init__(self, fspath, config): self.fspath = fspath self.config = config def __getattr__(self, name): - if not hasattr(self, "config"): - raise AttributeError("attribute config of %r not set" % self) - hookmethod = getattr(self.config.hook, name) + config = object.__getattribute__(self, "config") + hookmethod = getattr(config.hook, name) def call_matching_hooks(**kwargs): plugins = self.config._getmatchingplugins(self.fspath) diff --git a/testing/test_capture.py b/testing/test_capture.py index 6ddbf7e6e..0175ec285 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -1,7 +1,7 @@ # note: py.io capture tests where copied from # pylib 1.4.20.dev2 (rev 13d9af95547e) from __future__ import with_statement -import cPickle +import pickle import os import sys import py @@ -1026,9 +1026,9 @@ def test_error_attribute_issue555(testdir): def test_pickling_and_unpickling_enocded_file(): - # see - # https://bitbucket.org/hpk42/pytest/pull-request/194/fixed-strange-infinite-recursion-bug/diff + # See https://bitbucket.org/hpk42/pytest/pull-request/194 + # pickle.loads() raises infinite recursion if + # EncodedFile.__getattr__ is not implemented properly ef = capture.EncodedFile(None, None) - ef_as_str = cPickle.dumps(ef) - # this raises infinite recursion if EncodedFile.__getattr__ is not implemented properly: - cPickle.loads(ef_as_str) + ef_as_str = pickle.dumps(ef) + pickle.loads(ef_as_str)