CYGWIN: Python-3.16.0a1 doesn't select correct strerror_r()

未关闭 适合新手
#161,198 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
60/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
c

调研方向

该错误位于 Python/fileutils.c 中的 _Py_strerror,第 3319 行附近的预处理器代码块在 Py_STRERROR_R_GNU 与 XSI 变体之间做选择,而第 3353 和 3373 行附近的两个 strerror_r 调用在 Cygwin 上无法编译。请阅读该特性检测代码块以及报告者提出的 __CYGWIN__ 条件,然后检查 configure.ac 是否已经检测 strerror_r 的签名。完成的标准是:Cygwin 构建能够编译且没有 int-conversion 错误,并在该平台上选择 GNU 分支。

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

描述

build OS-unsupported OS-windows type-bug
Bug report

Python-3.16.0a1 has been released, so I tried to build it on Cygwin.
Unfortunately, this error happens:

Python-3.16.0a1/Python/fileutils.c: In function ‘_Py_strerror’:
Python-3.16.0a1/Python/fileutils.c:3353:15: error: initialization of ‘int’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion]
 3353 |     int len = strerror_r(code, small_buffer, buflen);
      |               ^~~~~~~~~~
Python-3.16.0a1/Python/fileutils.c:3373:17: error: assignment to ‘int’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion]
 3373 |             len = strerror_r(code, buffer, buflen);
      |                 ^
make: *** [Makefile:3361: Python/fileutils.o] Error 1

I'm thinking that this error comes from a recent change because I had not it in the past builds.
Evidently, Cygwin is also using the GNU version of strerror_r() but the current code doesn't take care of it.
At the moment, I fixed the error with this change:

--- origsrc/Python-3.16.0a1/Python/fileutils.c	2026-10-13 17:05:54.000000000 +0200
+++ src/Python-3.16.0a1/Python/fileutils.c	2026-11-02 13:13:18.366198700 +0100
@@ -3319,7 +3319,7 @@ _Py_strerror(int code)
    // Check which strerror_r() API is used
 #  if defined(__GLIBC__) && !((_POSIX_C_SOURCE >= 200112L) && !defined(_GNU_SOURCE))
 #    define Py_STRERROR_R_GNU
-#  elif defined(__ANDROID__) && defined(_GNU_SOURCE)
+#  elif (defined(__ANDROID__) || defined(__CYGWIN__)) && defined(_GNU_SOURCE)
 #    define Py_STRERROR_R_GNU
 #  endif
 #endif

However, is there a special reason because this test is not done at configure time?
Any comments?
See also issue #149879 "Enhance Cygwin support".

CPython versions tested on:

3.16

Operating systems tested on:

Windows

主要语言
Python
星标
77.8k
派生
37.7k
平均合并
17 小时 24 分钟
30 天内合并 PR
716

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

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

python/cpython 的其他 Issue

查看 python/cpython 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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