diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index 94ad4292ee2..b176dde98b9 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -77,12 +77,11 @@ def path(self) -> Union[py.path.local, str]: # maybe don't try this checking if not p.check(): raise OSError("py.path check failed.") + return p except OSError: # XXX maybe try harder like the weird logic # in the standard lib [linecache.updatecache] does? - p = self.raw.co_filename - - return p + return self.raw.co_filename @property def fullsource(self) -> Optional["Source"]: