Skip to content

Drop the free-threaded Python 3.13 code path - #1524

Merged
asvetlov merged 2 commits into
aio-libs:masterfrom
asvetlov:claude/drop-py3-13t-support-f2a1ba
Sep 23, 2026
Merged

asvetlov merged 2 commits into
aio-libs:masterfrom
asvetlov:claude/drop-py3-13t-support-f2a1ba

Conversation

@asvetlov

Copy link
Copy Markdown
Member

What do these changes do?

Support for free-threaded Python 3.13 was dropped in v6.8.0 (#1326),
once cibuildwheel stopped building cp313t wheels, but the C extension
kept a second free-threaded code path for interpreters without
PyUnstable_TryIncRef(), of which 3.13t is the only one. It was never
built in CI, never tested, and it duplicated md_get_one() and the
md_contains() dispatch outright.

Py_GIL_DISABLED now implies CPython 3.14 or newer. That assumption is
enforced by an #error in freethreading.h, so a free-threaded build
on 3.13t fails with a clear compiler message instead of silently
compiling an untested lock-free path (the vendored
pythoncapi_compat.h polyfills those calls, so it would otherwise
build). _MD_HAVE_TRYINCREF and every branch keyed on it are gone.

Only the C extension is affected. The pure-Python backend is
version-agnostic and unchanged, and builds with the GIL enabled still
go down to Python 3.10.

Are there changes in behavior for the user?

No, on every supported build. The disassembly of _multidict.so is
identical before and after on both a free-threaded 3.14t build and a
GIL build. On an unsupported free-threaded 3.13t interpreter, building
from source now fails at compile time rather than producing an
untested extension.

Is it a substantial burden for the maintainers to support this?

No, it removes code.

Related issue number

None; follow-up cleanup after #1326.

Checklist

  • I think the code is well written
  • Unit tests for the changes exist — N/A, no behaviour change; the
    existing free-threading tests cover the surviving path
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt — N/A, no such file in this repo
  • Add a new news fragment into the CHANGES/ folder
  • make doc-spelling passes and any new technical words are added to docs/spelling_wordlist.txt

Drafted with Claude Code (Opus 5); reviewed by @asvetlov.

Agent run details (optional, for reviewers)

Codegen check, per build, objdump -d with addresses normalised,
before vs. after: identical on 3.14.7t (free-threaded) and on 3.14.2
(GIL). The only difference is the file name in the objdump header.

Tests:

  • 3.14.7t, C extension: 2187 passed, 32 skipped
  • 3.13.12 GIL, C extension: 2198 passed, 21 skipped
  • 3.14.7t, --no-c-extensions: 1103 passed, 9 skipped
  • 3.14.7t, MULTIDICT_DEBUG_BUILD=1: 2187 passed, 32 skipped

Guard behaviour:

  • 3.13.7t built cleanly before this change; after it, the compile stops
    at freethreading.h:25:2: error: #error "the free-threaded build requires CPython 3.14 or newer".
  • GIL 3.13.12 still builds.

Lint: pre-commit run --all-files passed; make doc-spelling passed.

ThreadSanitizer was not run: the emitted code on 3.14t is unchanged, so
there is no new interleaving for it to exercise.

Support for 3.13t was dropped in v6.8.0, when cibuildwheel stopped
building cp313t wheels, but the C extension kept a second free-threaded
arm for interpreters without PyUnstable_TryIncRef(), which 3.13t is the
only one of. It was never built in CI and duplicated md_get_one() and
the md_contains() dispatch.

Py_GIL_DISABLED now implies CPython 3.14 or newer, enforced by an
#error in freethreading.h so an unsupported free-threaded build fails
loudly instead of silently compiling an untested path. GIL builds are
unaffected down to 3.10.
@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided There is a change note present in this PR label Sep 22, 2026
@codspeed

codspeed Bot commented Sep 22, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 298 untouched benchmarks


Comparing asvetlov:claude/drop-py3-13t-support-f2a1ba (8808c1e) with master (1cdd934)

Open in CodSpeed

@asvetlov
asvetlov marked this pull request as ready for review September 23, 2026 09:53
@asvetlov
asvetlov requested a review from webknjaz as a code owner September 23, 2026 09:53
@greptile-apps

greptile-apps Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

Safe to merge: the supported GIL-enabled build remains intact, and unsupported older free-threaded builds are rejected clearly.

What we checked:

  • Before GIL run, the regression workflow built the C extensions and ran the tests, resulting in a successful build and 568 tests passing with 6 skipped. T-Rex
  • After GIL run, the same build and test commands were executed at PR HEAD and produced the same successful results: the build succeeded, with 568 tests passing and 6 skipped. T-Rex
  • Before the guard check, the guard probe was preprocessed and produced exit code 0, confirming no predecessor rejection guard was present. T-Rex
  • After the guard check, the same probe was preprocessed and produced exit code 1 with the intended compiler error, validating the guard behavior. T-Rex
  • All authored scripts, the shared probe source, and the observed command outputs were saved in trex-artifacts for reviewer access. T-Rex

Reviews (1) · Last reviewed commit: "Rename the news fragment to the assigned..."

@asvetlov
asvetlov merged commit 690e43c into aio-libs:master Sep 23, 2026
61 checks passed
@asvetlov
asvetlov deleted the claude/drop-py3-13t-support-f2a1ba branch September 23, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided There is a change note present in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant