🐛 fix(spec): discover debug (Py_DEBUG) interpreters like python3.13-dbg#96
Merged
Merged
Conversation
python3.13-dbg parsed as version 3.13 with machine="dbg", so a real Py_DEBUG interpreter was rejected during discovery. Recognize d, -dbg and -debug as a debug-build marker instead, matching against PythonInfo.debug_build. Absent a marker the build type stays unconstrained, so release specs behave as before. Fixes tox-dev/tox#3977.
Debian, Fedora and upstream all install the abiflags-suffixed debug binary (pythonX.Yd, pythonX.Ytd), but _find_possible_exe_names only generated the Windows (_d) and Debian (-dbg) forms, so venv-to-system resolution missed it. Add the d suffix. Sync the spec-format docs across all Diataxis sections: add the debug node to both grammar diagrams, document the t-before-d and arch-before- machine ordering, list debug_build in the metadata reference, and add a how-to for selecting a debug build.
discover_exe matched a base interpreter by name, version, implementation and architecture, but not by its ABI flags. A debug or free-threaded virtualenv could therefore resolve to a release build of the same version. Compare free_threaded and debug_build too, so the runtime value confirms the name-level match.
gaborbernat
approved these changes
Jul 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Debian and Ubuntu ship their
Py_DEBUGinterpreter aspython3.13-dbg, but that spec failed to resolve. 🐛 The parser read the-dbgsuffix as a machine (ISA) nameddbg, and because the real binary reports its true architecture (arm64,x86_64, and so on), no interpreter matched. This surfaced in tox-dev/tox#3977, wherebase_python = python3.13-dbgfell over with "could not find python interpreter".The spec grammar now carries a debug flag next to the free-threaded
tflag. ✨ It accepts the ABI-flag formpython3.13dand Debian'spython3.13-dbg/python3.13-debug, then matches that flag against the interpreter'sPy_DEBUGbuild setting during discovery. A lookahead anchors the marker so it leaves the ISA intact:cpython3.12-64-arm64still readsarm64as the machine. The generated filename pattern and the by-name executable search gained the same forms, so a Debian-dbgbinary also resolves through the venv-to-system walk.The flag defaults to unconstrained. A versioned spec with no marker keeps matching either build type, so no existing spec shifts meaning; only an explicit
d/-dbg/-debugnarrows the search to a debug interpreter.