https://github.com/python/cpython/commit/95e4f06e919556f5bfeafdaa1f9ebb88acece0c2
commit: 95e4f06e919556f5bfeafdaa1f9ebb88acece0c2
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: vstinner <[email protected]>
date: 2026-11-07T01:00:19Z
summary:

[3.15] gh-161517: Fix test_gdb on GHA Hypothesis tests (GH-161519) (#161525)

gh-161517: Fix test_gdb on GHA Hypothesis tests (GH-161519)

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.
(cherry picked from commit ce4ac8c0459eba99459f03824cf1ac195c1aa7a1)

Co-authored-by: Victor Stinner <[email protected]>

files:
A Misc/NEWS.d/next/Tests/2026-11-06-23-15-23.gh-issue-161517.LkAlDt.rst
M Lib/test/test_gdb/util.py

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.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to