Skip to content

Commit cfc955c

Browse files
author
Lev Maximov
committed
AttributeError chaining bug pytest-dev#1944 fix
1 parent 2bafa74 commit cfc955c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

_pytest/python.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,10 @@ class PyobjContext(object):
205205
class PyobjMixin(PyobjContext):
206206
def obj():
207207
def fget(self):
208-
try:
209-
return self._obj
210-
except AttributeError:
208+
obj = getattr(self, '_obj', None)
209+
if obj is None:
211210
self._obj = obj = self._getobj()
212-
return obj
211+
return obj
213212
def fset(self, value):
214213
self._obj = value
215214
return property(fget, fset, None, "underlying python object")

0 commit comments

Comments
 (0)