python / python/cpython

C API: Enable limited C API tests on Free Threading

未关闭
#155,561 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

tests topic-C-API
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

Currently, the _testlimitedcapi extension module is not built with the limited C API on Free Threading which is misleading and defeats the purpose of this extension.

PEP 803 added Py_TARGET_ABI3T macro to Python 3.15 which makes it possible to build a C extension using the limited C API when using Free Threading. So I propose building _testlimitedcapi using Py_TARGET_ABI3T to test properly the limited C API on Free Threading.

One limitation is that Py_TARGET_ABI3T minimum version is Python 3.15, whereas _testlimitedcapi/<file>.c files target older Python versions. Anyway, we have to only define Py_TARGET_ABI3T on Free Threading, or define Py_LIMITED_API macro otherwise (build with GIL). Example:

#include "pyconfig.h"   // Py_GIL_DISABLED
#ifdef Py_GIL_DISABLED
#  define Py_TARGET_ABI3T 0x030f0000
#else
   // Need limited C API version 3.13 for Py_GetConstant()
#  define Py_LIMITED_API 0x030d0000
#endif
Linked PRs
  • gh-155570
  • gh-155693
  • gh-156052

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

先从 issue 中描述的 _testlimitedcapi/.c 源文件和 pyconfig.h 宏开始,然后检查 _testlimitedcapi 是如何为 Free Threading 构建的。检查 _testlimitedcapi 扩展中的 limited C API 测试,并确认它们在 Free Threading 上使用 Py_TARGET_ABI3T 构建和运行,同时为 GIL 构建保留 Py_LIMITED_API。

由索引模型根据 Issue 内容生成。

评估

技术栈
c, python
领域
testing-qa
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。