python / python/cpython

-m trace --count missing lines

未關閉
#142,867 0 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

stdlib type-bug
主要語言
Python
星號
77.2k
分支
36k
PR 合併指標
PR 指標待擷取

描述

Bug report

Bug description:
def x() -> tuple[
        int,
]:
    return (1, 'fred')

x()

python 3.13 (good):

xju@xjutv:~/tmp$ python3 --version
Python 3.13.1
xju@xjutv:~/tmp$ rm -f xxx.cover
xju@xjutv:~/tmp$ python3 -m trace --count -m xxx.py
xju@xjutv:~/tmp$ cat xxx.cover
    2: def x() -> tuple[
    1:         int,
       ]:
    1:     return (1, 'fred')
       
    1: x()

python 3.14 (bad):

xju@xjutv:~/tmp$ python3 --version
Python 3.14.2
xju@xjutv:~/tmp$ rm -f xxx.cover
xju@xjutv:~/tmp$ python3 -m trace --count -m xxx.py
xju@xjutv:~/tmp$ cat xxx.cover
    1: def x() -> tuple[
>>>>>>         int,
       ]:
    1:     return (1, 'fred')
       
    1: x()

... trace._get_executable_linenos returns the same in both 3.13 and 3.14; seems that Trace.run does not see that the type hint is "executed"? Could equally have trace._get_executable_linenos not report the type hint... they just need to agree.

Above is about the simplest example I came up with, but similar disagreement with class attribute hints like:

class X:
  a: int

... a: int is reported as "not covered".

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Linked PRs
  • gh-143161

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

使用 Python 程式碼片段重現差異,並比較 3.13 和 3.14 的 coverage 輸出。檢查 trace.Trace.run 和 trace._get_executable_linenos;報告指出它們對於已執行的註解存在不一致。完成標準是兩條路徑達成一致,並且包含 type hint 的行(包括類別屬性 hint)獲得一致的 coverage 結果。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
tooling
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。