Repository navigation
Add Python 3.14 and free-threaded (3.14t) support - #44
Merged
Merged
Conversation
- Build and test on Python 3.14 and 3.14t in CI and the publish workflow - Declare GIL-free support and serialize type mutations on free-threaded builds (guarded by Py_GIL_DISABLED) - Fix reference leaks in all slot implementations - Fix __getitem__ not receiving the key, __setitem__/__delitem__ failing, __index__ and Py_ssize_t sequence slots crashing, __iadd__ using the wrong sequence slot, __hash__ returning -1 and __bool__ error handling - Invalidate the type attribute cache when extending a type, which could crash after the replaced method was freed - Remove `del _T`, which breaks lazily evaluated annotations on 3.14 - Run the Windows publish job on windows-latest (windows-2019 is retired) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
elazarcoh
approved these changes
Oct 27, 2026
Closed
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.
Summary
Free-threading
#ifdef Py_GIL_DISABLED, viaTYPE_MUTATION_LOCK()/TYPE_MUTATION_UNLOCK()(aPyMutex) andSTORE_SLOT()(an atomic pointer store). On regular builds they compile to nothing / a plain assignment.PyUnstable_Module_SetGIL(Py_MOD_GIL_NOT_USED), so importing extype doesn't re-enable the GIL.extend_type_withnow sets the attribute before enabling the slot, so a slot is never active without a method behind it.Bug fixes
Each of these was reproduced on
mainbefore fixing:PyTuple_Pack/PyObject_GetAttrStringresults never released).__getitem__was called without the key.__setitem__/__delitem__failed because theNonereturn value was converted to an integer.__index__was implemented as a binary function for a unary slot → segfault.sq_item,sq_ass_item,sq_repeat,sq_inplace_repeattake aPy_ssize_t, but got object-based implementations → segfault. They now have dedicated implementations.__iadd__on sequence-only types usedsq_inplace_repeatinstead ofsq_inplace_concat.__hash__returning-1caused aSystemError; it now maps to-2like Python does.__bool__continued after setting an error.get_type_dictadded an extra reference on 3.12+.set_type_attributewrites the attribute and callsPyType_Modified.del _Tinextension_utils.pybreaks lazily evaluated annotations on 3.14 (typing.get_type_hints(extension)raisedNameError, and flake8 on 3.14 fails CI on it).CI / packaging
3.14to all workflow matrices, and3.14tto the Windows/macOS publish jobs and all test workflows. On Linux, cibuildwheel already buildscp314tfrom the3.14entry (checked with--print-build-identifiers).windows-latest, since thewindows-2019runner is retired.Testing
tests/test_slot_implementations.py: regression tests for the bugs above. Six of the seven fail or crash onmain.tests/test_free_threading.py: checks that the GIL stays disabled, and runs extensions concurrently with readers and with other writers.🤖 Generated with Claude Code