__code__ and __self__ are attributes in python2.6+

This commit is contained in:
Anthony Sottile 2018-06-03 11:57:32 -07:00
parent 3d0717813a
commit 04f08b67a4
2 changed files with 2 additions and 3 deletions

View File

@ -83,7 +83,7 @@ def iscoroutinefunction(func):
def getlocation(function, curdir):
fn = py.path.local(inspect.getfile(function))
lineno = py.builtin._getcode(function).co_firstlineno
lineno = function.__code__.co_firstlineno
if fn.relto(curdir):
fn = fn.relto(curdir)
return "%s:%d" % (fn, lineno + 1)

View File

@ -354,8 +354,7 @@ class FixtureRequest(FuncargnamesCompatAttr):
return self._pyfuncitem._testcase
except AttributeError:
function = getattr(self, "function", None)
if function is not None:
return py.builtin._getimself(function)
return getattr(function, "__self__", None)
@scopeproperty()
def module(self):