Skip to content

🐛 fix(spec): discover debug (Py_DEBUG) interpreters like python3.13-dbg#96

Merged
gaborbernat merged 4 commits into
tox-dev:mainfrom
ychampion:fix-dbg-python-spec
Jul 8, 2026
Merged

🐛 fix(spec): discover debug (Py_DEBUG) interpreters like python3.13-dbg#96
gaborbernat merged 4 commits into
tox-dev:mainfrom
ychampion:fix-dbg-python-spec

Conversation

@ychampion

@ychampion ychampion commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Debian and Ubuntu ship their Py_DEBUG interpreter as python3.13-dbg, but that spec failed to resolve. 🐛 The parser read the -dbg suffix as a machine (ISA) named dbg, 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, where base_python = python3.13-dbg fell over with "could not find python interpreter".

The spec grammar now carries a debug flag next to the free-threaded t flag. ✨ It accepts the ABI-flag form python3.13d and Debian's python3.13-dbg / python3.13-debug, then matches that flag against the interpreter's Py_DEBUG build setting during discovery. A lookahead anchors the marker so it leaves the ISA intact: cpython3.12-64-arm64 still reads arm64 as the machine. The generated filename pattern and the by-name executable search gained the same forms, so a Debian -dbg binary 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 / -debug narrows the search to a debug interpreter.

Copilot AI review requested due to automatic review settings July 8, 2026 20:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.
@gaborbernat gaborbernat added the bug Something isn't working label Jul 8, 2026
@gaborbernat gaborbernat changed the title Fix debug-suffixed Python specs 🐛 fix(spec): discover debug (Py_DEBUG) interpreters like python3.13-dbg Jul 8, 2026
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 gaborbernat merged commit 4dbf5d1 into tox-dev:main Jul 8, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants