python / python/pythoncapi-compat
upgrade_pythoncapi.py: Wrong transformations for Py_Is
未关闭
还没有人认领这个 Issue。
- 主要语言
- C
- 星标
- 110
- 派生
- 39
- 平均合并
- 8 分钟
- 30 天内合并 PR
- 2
描述
Consider an example:
if (((PyObject*)obj)->data == Py_None) {
111;
}
if (Py_None == ((PyObject*)obj)->data) {
111;
}
After upgrade_pythoncapi.py I got:
#include "pythoncapi_compat.h"
if (((PyObject*)obj)->Py_IsNone(data)) {
111;
}
if (Py_None == ((PyObject*)obj)->data) {
111;
}
Real world example:
https://github.com/aleaxit/gmpy/blob/eb8dfcbd84abcfcb36b4adcb0d5c6d050731dd75/src/gmpy2_xmpz_misc.c#L237
I'm not sure if this is a bug. This kind of issues is not easy to avoid, using regexps for code transformations. Have you considered to use something like the pycparser?
Thanks for the project.
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 upgrade_pythoncapi.py 开始,复现 issue 中的两个 C 示例,然后将输出与引用的 gmpy2_xmpz_misc.c 案例进行比较。检查该转换是否能处理两种操作数顺序而不破坏成员访问;当使用预期的 Py_IsNone 转换生成有效的 C 时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- c, python
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100