diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2021-07-20 06:54:22 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2021-07-20 05:32:28 -0700 |
commit | 5313297fe84c596f9222a4890dd45a53a6d4d632 (patch) | |
tree | ceacf73477e129786a8566fff146c18cd57c0edf /coverage/parser.py | |
parent | de38a0e74a8683a3d3381038aeee4d226cc5b714 (diff) | |
download | python-coveragepy-git-5313297fe84c596f9222a4890dd45a53a6d4d632.tar.gz |
fix: raise chained errors with "from" #998
This makes exceptions report their causes correctly, as "The above exception was
the direct cause of the following exception" instead of "During handling of the
above exception, another exception occurred."
Diffstat (limited to 'coverage/parser.py')
-rw-r--r-- | coverage/parser.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/coverage/parser.py b/coverage/parser.py index abaa2e50..ed049685 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -41,9 +41,7 @@ class PythonParser: try: self.text = get_python_source(self.filename) except OSError as err: - raise NoSource( - f"No source for code: '{self.filename}': {err}" - ) + raise NoSource(f"No source for code: '{self.filename}': {err}") from err self.exclude = exclude @@ -243,7 +241,7 @@ class PythonParser: "Couldn't parse '%s' as Python source: '%s' at line %d" % ( self.filename, err.args[0], lineno ) - ) + ) from err self.excluded = self.first_lines(self.raw_excluded) @@ -363,7 +361,7 @@ class ByteParser: "Couldn't parse '%s' as Python source: '%s' at line %d" % ( filename, synerr.msg, synerr.lineno ) - ) + ) from synerr # Alternative Python implementations don't always provide all the # attributes on code objects that we need to do the analysis. |