Dead code in tkinter
未關閉
還沒有人認領這個 Issue。
3.16
extension-modules
topic-tkinter
type-refactor
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 35.9k
- PR 合併指標
- PR 指標待擷取
描述
Bug report
Bug description:
Modules/_tkinter.c always defines TCL_THREADS:
/* If Tcl is compiled for threads, we must also define TCL_THREAD. We define
it always; if Tcl is not threaded, the thread functions in
Tcl are empty. */
#define TCL_THREADS
but in two places in Modules/_tkinter.c , we check if TCL_THREADS is defined:
#ifdef TCL_THREADS
static Tcl_ThreadDataKey state_key;
typedef PyThreadState *ThreadSpecificData;
#define tcl_tstate \
(*(PyThreadState**)Tcl_GetThreadData(&state_key, sizeof(PyThreadState*)))
#else
static PyThreadState *tcl_tstate = NULL;
#endif
and
#ifndef TCL_THREADS
if (v->threaded) {
PyErr_SetString(PyExc_RuntimeError,
"Tcl is threaded but _tkinter is not");
Py_DECREF(v);
return 0;
}
#endif
Especially the latter is confusing, as this code block is not compiled and the test is never executed.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
- gh-141241
- gh-152841
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 Modules/_tkinter.c 開始,閱讀 TCL_THREADS 定義和報告中顯示的兩個條件區塊,然後檢視連結的 PR gh-141241 和 gh-152841,以了解現有的工作。完成的標準是:一致地移除或釐清無法到達的條件程式碼,且不留下報告中指出的死路徑。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- c
- 領域
- desktop
- Issue 類型
- 重構
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 35/100