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
派生
35.9k
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 摘要。