From f42ade04a608cfad16cfee749e1672f65eff523c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Labb=C3=A9?= Date: Thu, 27 Jan 2022 09:54:33 +0100 Subject: [PATCH] 33231: add try except clause to catch OSError during run --- src/sage/features/lrs.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/sage/features/lrs.py b/src/sage/features/lrs.py index 7031982797b..f6a4d922bd0 100644 --- a/src/sage/features/lrs.py +++ b/src/sage/features/lrs.py @@ -47,7 +47,12 @@ def is_functional(self): with open(tf_name, 'w') as tf: tf.write("V-representation\nbegin\n 1 1 rational\n 1 \nend\nvolume") command = ['lrs', tf_name] - result = subprocess.run(command, capture_output=True, text=True) + try: + result = subprocess.run(command, capture_output=True, text=True) + except OSError as e: + return FeatureTestResult(self, False, reason='Running command "{}" ' + 'raised an OSError "{}" '.format(' '.join(command), e)) + if result.returncode: return FeatureTestResult(self, False, reason="Call to `{command}` failed with exit code {result.returncode}.".format(command=" ".join(command), result=result)) @@ -67,7 +72,11 @@ def is_functional(self): with open(tf_name, 'w') as tf: tf.write("1 1\n \n 0\n \n 0\n") command = ['lrsnash', tf_name] - result = subprocess.run(command, capture_output=True, text=True) + try: + result = subprocess.run(command, capture_output=True, text=True) + except OSError as e: + return FeatureTestResult(self, False, reason='Running command "{}" ' + 'raised an OSError "{}" '.format(' '.join(command), e)) if result.returncode: return FeatureTestResult(self, False, reason='Running command "{}" ' 'returned non-zero exit status "{}" with stderr '