Skip to content

Commit

Permalink
code: remove last usage of py.error
Browse files Browse the repository at this point in the history
`str(self.path)` can't raise at all, so it can just be removed.
  • Loading branch information
bluetech committed May 28, 2020
1 parent b3db440 commit 2ee9088
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/_pytest/_code/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,18 +268,14 @@ def ishidden(self):
return tbh

def __str__(self) -> str:
try:
fn = str(self.path)
except py.error.Error:
fn = "???"
name = self.frame.code.name
try:
line = str(self.statement).lstrip()
except KeyboardInterrupt:
raise
except BaseException:
line = "???"
return " File %r:%d in %s\n %s\n" % (fn, self.lineno + 1, name, line)
return " File %r:%d in %s\n %s\n" % (self.path, self.lineno + 1, name, line)

@property
def name(self) -> str:
Expand Down

0 comments on commit 2ee9088

Please sign in to comment.