Skip to content

cffi-gen-src output varies depending on running interpreter #267

Description

@ngoldbaum

While working on hynek/argon2-cffi-bindings#137, I noticed that the output of cffi-gen-src is different for a free-threaded and GIL-enabled interpreter.

Self-contained reproducer:

$ cat demo_build.py
from cffi import FFI
ffibuilder = FFI()
ffibuilder.cdef("int square(int n);")
ffibuilder.set_source("_demo", "static int square(int n) { return n * n; }")
$
$ python3.14 -m cffi.gen_src exec-python demo_build.py demo-gil.c
$ python3.14t -m cffi.gen_src exec-python demo_build.py demo-ft.c
$ diff -u demo-gil.c demo-ft.c
--- demo-gil.c	2026-07-28 14:57:58
+++ demo-ft.c	2026-07-28 14:58:20
@@ -1,3 +1,4 @@
+#define _CFFI_NO_LIMITED_API
 #define _CFFI_

 /* We try to define Py_LIMITED_API before including Python.h.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions