Skip to content

Fix: support CPython free-threaded builds (3.14t)#746

Open
MilesCranmerBot wants to merge 2 commits intoJuliaPy:mainfrom
MilesCranmerBot:bot/fix-pythoncall-py314t
Open

Fix: support CPython free-threaded builds (3.14t)#746
MilesCranmerBot wants to merge 2 commits intoJuliaPy:mainfrom
MilesCranmerBot:bot/fix-pythoncall-py314t

Conversation

@MilesCranmerBot
Copy link

Supports CPython free-threaded builds (ABI tag "t", e.g. python3.14t) by:

  • recording whether the loaded libpython is free-threaded (via Py_GetVersion() string)
  • adding parallel FT header structs (PyObjectFT/PyVarObjectFT/etc) while keeping existing PyObject layouts
  • avoiding direct PyTypeObject field peeks in hot paths: use PyType_GetFlags + PyType_GetSlot
  • fixing Juliacall heap type layout/alloc/free to respect the FT header size

Local testing (Julia 1.10.10):

  • Smoke: pyimport("sys").version works for python 3.13.11 and python 3.14.2t
  • Pkg.test("PythonCall") PASS under both interpreters using JULIA_PYTHONCALL_EXE set accordingly.

Commit: 5783d27

Co-authored-by: Miles Cranmer <miles.cranmer@gmail.com>
@MilesCranmer
Copy link
Contributor

MilesCranmer commented Feb 5, 2026

@cjdoris just confirming this is indeed my AI agent 😅 I just skimmed the PR now and it looks fine to me. It passes tests on both Python 3.13 and 3.14t.

It doesn't do anything special to integrate the threading, though, and perhaps that might require more thinking. What this does do, though, is make tests pass without segfaulting (since the C types are slightly different).


Explanation if needed: I let this agent run autonomously (OpenClaw + Codex), without needing my approval for commands: post. However, due to the inherent security risks of that, it (1) runs in a cloud VPS that has no access to my data or credentials, and (2) has a completely separate GitHub and email account. That way, it never inherits write access from my account or is able to read any secrets. Think of it like any untrusted external contributor who gets advice on how to implement something.

Anyways: this PR was prompted by my request to it (I basically text it instructions), along with the basic design and requirements. (I also find it convenient to let the agent submit its own PRs, hope that's ok!)

Co-authored-by: Miles Cranmer <miles.cranmer@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants