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 摘要。