Incorrect information about exception raised if source contains null bytes for ast.parse() and compile()
未關閉
還沒有人認領這個 Issue。
3.12
3.13
3.14
docs
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
Documentation
Docs for compile() and ast.parse() say they raise ValueError for source contains null bytes. However, since 3.12 (https://github.com/python/cpython/pull/97594), SyntaxError is raised instead:
>>> compile("\x00", "lambda.tt", "exec")
Traceback (most recent call last):
File "<python-input-0>", line 1, in <module>
compile("\x00", "lambda.tt", "exec")
~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: source code string cannot contain null bytes
https://github.com/python/cpython/blob/d1a1bca1f0550a4715f1bf32b1586caa7bc4487b/Doc/library/functions.rst?plain=1#L337-L338
And
https://github.com/python/cpython/blob/d1a1bca1f0550a4715f1bf32b1586caa7bc4487b/Doc/library/ast.rst?plain=1#L2158
Linked PRs
- gh-122462
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
先從 Doc/library/functions.rst 和 Doc/library/ast.rst 中被引用的條目開始,然後查看連結的 PR gh-122462 以了解目前的工作。更新文件中的例外,使其與 Python 3.12 的行為一致,並驗證受影響的兩個文件區段保持一致。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- documentation
- Issue 類型
- 文件
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 35/100