From e6b5fc01344c50179bf50e5e87f946db30104c16 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 6 Nov 2026 23:11:03 +0100 Subject: [PATCH] gh-161517: Fix test_gdb on GHA Hypothesis tests Fix test_gdb when Python is built out-of-tree and Python is run from a virtual environment. Previously, test_gdb was just skipped. Fix CHECKOUT_HOOK_PATH in test_gdb.util: get python-gdb.py from the build directory, rather than using the sys.executable directory. --- Lib/test/test_gdb/util.py | 11 +++++++++-- .../2026-11-06-23-15-23.gh-issue-161517.LkAlDt.rst | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Tests/2026-11-06-23-15-23.gh-issue-161517.LkAlDt.rst diff --git a/Lib/test/test_gdb/util.py b/Lib/test/test_gdb/util.py index 29c7e9ee8f05498..ffe92137d844b71 100644 --- a/Lib/test/test_gdb/util.py +++ b/Lib/test/test_gdb/util.py @@ -11,9 +11,16 @@ GDB_PROGRAM = shutil.which('gdb') or 'gdb' +# First, try to use the build directory to support out-of-tree build +for key in ('abs_builddir', 'abs_srcdir', 'srcdir'): + SRC_DIR = sysconfig.get_config_var(key) + if SRC_DIR: + break +else: + raise Exception("unable to get the Python source directory") + # Location of custom hooks file in a repository checkout. -CHECKOUT_HOOK_PATH = os.path.join(os.path.dirname(sys.executable), - 'python-gdb.py') +CHECKOUT_HOOK_PATH = os.path.join(SRC_DIR, 'python-gdb.py') SAMPLE_SCRIPT = os.path.join(os.path.dirname(__file__), 'gdb_sample.py') BREAKPOINT_FN = 'builtin_id' diff --git a/Misc/NEWS.d/next/Tests/2026-11-06-23-15-23.gh-issue-161517.LkAlDt.rst b/Misc/NEWS.d/next/Tests/2026-11-06-23-15-23.gh-issue-161517.LkAlDt.rst new file mode 100644 index 000000000000000..fc76d235d207f0e --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2026-11-06-23-15-23.gh-issue-161517.LkAlDt.rst @@ -0,0 +1,3 @@ +Fix test_gdb when Python is built out-of-tree and Python is run from a +virtual environment. Previously, test_gdb was just skipped. Patch by Victor +Stinner.