Merge pull request #6868 from bluetech/simplify-exc

Simplify some exception handling code
This commit is contained in:
Ran Benita
2020-03-10 20:32:08 +02:00
committed by GitHub
5 changed files with 32 additions and 43 deletions

View File

@@ -513,8 +513,7 @@ class Module(nodes.File, PyCollector):
mod = self.fspath.pyimport(ensuresyspath=importmode)
except SyntaxError:
raise self.CollectError(ExceptionInfo.from_current().getrepr(style="short"))
except self.fspath.ImportMismatchError:
e = sys.exc_info()[1]
except self.fspath.ImportMismatchError as e:
raise self.CollectError(
"import file mismatch:\n"
"imported module %r has this __file__ attribute:\n"