Skip to content

Commit 2777a08

Browse files
committed
ctypes: correct gcc check in test
In case gcc is not available, it will throw exception and test fails. So catch the exception to skip the test correctly. ====================================================================== ERROR: test_null_dlsym (test.test_ctypes.test_dlerror.TestNullDlsym.test_null_dlsym) ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/python3.12/test/test_ctypes/test_dlerror.py", line 61, in test_null_dlsym retcode = subprocess.call(["gcc", "--version"], ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/subprocess.py", line 391, in call with Popen(*popenargs, **kwargs) as p: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/subprocess.py", line 1028, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/lib/python3.12/subprocess.py", line 1963, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'gcc' Signed-off-by: Peter Marko <[email protected]>
1 parent d5796e6 commit 2777a08

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Lib/test/test_ctypes/test_dlerror.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,14 @@ def test_null_dlsym(self):
5858
import subprocess
5959
import tempfile
6060

61-
retcode = subprocess.call(["gcc", "--version"],
62-
stdout=subprocess.DEVNULL,
63-
stderr=subprocess.DEVNULL)
64-
if retcode != 0:
61+
try:
62+
retcode = subprocess.call(["gcc", "--version"],
63+
stdout=subprocess.DEVNULL,
64+
stderr=subprocess.DEVNULL)
65+
except FileNotFoundError:
6566
self.skipTest("gcc is missing")
67+
if retcode != 0:
68+
self.skipTest("gcc --version failed")
6669

6770
pipe_r, pipe_w = os.pipe()
6871
self.addCleanup(os.close, pipe_r)

0 commit comments

Comments
 (0)