python / python/cpython

Argument Clinic does not check the length of parameter descriptions

未關閉
#155,228 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

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

描述

Bug report

The docstring line length check is performed before the parameter descriptions are added to the docstring:

        max_width = f.docstring_line_width
        summary_len = len(lines[0])
        max_body = max(map(len, lines[1:]))
        ...
        if not parameters_marker_count:
            lines.insert(2, '{parameters}')

So a description of any length is accepted without a warning.

24 functions in the current tree have parameter description lines longer than the limit (the number of too long lines is in parentheses):

  • _lzma.LZMADecompressor (4)
  • select.epoll (3)
  • int.to_bytes (2)
  • select.kqueue.control (2)
  • str.encode (2)
  • winreg.SetValueEx (2)
  • _sqlite3.Connection.getconfig
  • _sqlite3.Connection.setconfig
  • _sre.template
  • _winapi.RegisterEventSource
  • _zstd.ZstdCompressor.set_pledged_input_size
  • bytearray.decode
  • bytearray.rsplit
  • bytearray.split
  • bytearray.take_bytes
  • bytes.decode
  • bytes.rsplit
  • bytes.split
  • gc.set_debug
  • os.timerfd_create
  • select.poll.poll
  • winreg.ConnectRegistry
  • winreg.DeleteTree
  • zlib._ZlibDecompressor

This is easy to miss for a cloned function, which inherits the descriptions of the function it clones: bytes.split and bytes.rsplit (and the bytearray pair) both have a 69 character line, and rewrapping the description in bytes.split does not make Argument Clinic report anything for either of them.

This is a leftover of #150285.

Linked PRs
  • gh-155251

貢獻指南

開啟貢獻指南

從這裡開始

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

研究方向

從 issue 中展示的 Argument Clinic docstring 行長度檢查開始,並檢視 #150285 的上下文。使用列出的受影響函式,包括 bytes.split 和 bytes.rsplit 這樣的複製函式對,驗證是否能偵測到過長的參數描述,以及連結的 PR gh-155251 是否反映了已完成的行為。

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

評估

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

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

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