From: Peter Marko Date: Mon, 10 Feb 2025 09:51:56 +0000 (+0100) Subject: gh-126554: correct detection of `gcc` for `TestNullDlsym.test_null_dlsym` (GH-129872) X-Git-Tag: v3.14.0a5~18 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=978211c8a8646b050a8d687ca720f934fcce112c;p=thirdparty%2FPython%2Fcpython.git gh-126554: correct detection of `gcc` for `TestNullDlsym.test_null_dlsym` (GH-129872) In case gcc is not available, the test will fail with FileNotFoundError. So catch the exception to skip the test correctly. Signed-off-by: Peter Marko --- diff --git a/Lib/test/test_ctypes/test_dlerror.py b/Lib/test/test_ctypes/test_dlerror.py index 6bf492399cbf..1c1b2aab3d58 100644 --- a/Lib/test/test_ctypes/test_dlerror.py +++ b/Lib/test/test_ctypes/test_dlerror.py @@ -58,11 +58,14 @@ class TestNullDlsym(unittest.TestCase): import subprocess import tempfile - retcode = subprocess.call(["gcc", "--version"], - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL) - if retcode != 0: + try: + retcode = subprocess.call(["gcc", "--version"], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL) + except OSError: self.skipTest("gcc is missing") + if retcode != 0: + self.skipTest("gcc --version failed") pipe_r, pipe_w = os.pipe() self.addCleanup(os.close, pipe_r)