summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2021-02-10 14:46:01 -0600
committerGitHub <noreply@github.com>2021-02-10 14:46:01 -0600
commit26e0003573463d0c5ca6c07289cd5151b4dba3b2 (patch)
tree49fe2ec5439d5434fa43e580a7797b33d3841b13
parent7b0653cdd0d0a5ddcda061ee2eaf247f6303bc1e (diff)
parentb62ffc5a3584f6f946b7fbc37336d2cd63ea943d (diff)
downloadnumpy-26e0003573463d0c5ca6c07289cd5151b4dba3b2.tar.gz
Merge pull request #18274 from tautaus/master
MAINT: Chain exceptions in linalg
-rwxr-xr-xnumpy/linalg/lapack_lite/make_lite.py4
-rw-r--r--numpy/linalg/tests/test_build.py4
-rw-r--r--numpy/linalg/tests/test_linalg.py4
3 files changed, 6 insertions, 6 deletions
diff --git a/numpy/linalg/lapack_lite/make_lite.py b/numpy/linalg/lapack_lite/make_lite.py
index cf15b2541..b145f6c4f 100755
--- a/numpy/linalg/lapack_lite/make_lite.py
+++ b/numpy/linalg/lapack_lite/make_lite.py
@@ -261,8 +261,8 @@ def runF2C(fortran_filename, output_dir):
subprocess.check_call(
["f2c"] + F2C_ARGS + ['-d', output_dir, fortran_filename]
)
- except subprocess.CalledProcessError:
- raise F2CError
+ except subprocess.CalledProcessError as e:
+ raise F2CError from e
def scrubF2CSource(c_file):
with open(c_file) as fo:
diff --git a/numpy/linalg/tests/test_build.py b/numpy/linalg/tests/test_build.py
index 4859226d9..868341ff2 100644
--- a/numpy/linalg/tests/test_build.py
+++ b/numpy/linalg/tests/test_build.py
@@ -15,8 +15,8 @@ class FindDependenciesLdd:
try:
p = Popen(self.cmd, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
- except OSError:
- raise RuntimeError(f'command {self.cmd} cannot be run')
+ except OSError as e:
+ raise RuntimeError(f'command {self.cmd} cannot be run') from e
def get_dependencies(self, lfile):
p = Popen(self.cmd + [lfile], stdout=PIPE, stderr=PIPE)
diff --git a/numpy/linalg/tests/test_linalg.py b/numpy/linalg/tests/test_linalg.py
index 21fab58e1..8a270f194 100644
--- a/numpy/linalg/tests/test_linalg.py
+++ b/numpy/linalg/tests/test_linalg.py
@@ -348,10 +348,10 @@ class LinalgTestCase:
try:
case.check(self.do)
- except Exception:
+ except Exception as e:
msg = f'In test case: {case!r}\n\n'
msg += traceback.format_exc()
- raise AssertionError(msg)
+ raise AssertionError(msg) from e
class LinalgSquareTestCase(LinalgTestCase):