`re` docs never say that the ASCII flag affects `\p{...}` properties
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 35.9k
- PR 合併指標
- PR 指標待擷取
描述
Documentation
https://docs.python.org/dev/library/re.html#re.A
The re.ASCII entry lists \w, \W, \b, \B, \d, \D, \s and \S as the constructs it restricts, and the \p{property=value} section never mentions the flags. Six accepted property spellings are restricted by the flag as well, because Nd, digit, word, space, White_Space and WSpace are matched with the same engine categories as \d, \s and \w. The other 52 accepted spellings are unaffected.
$ cat repro.py
import re
s = '0\u0663 \xa0x'
for p in 'Nd', 'digit', 'word', 'space', 'White_Space', 'WSpace':
pat = r'\p{%s}' % p
print('%-12s %-18r %r' % (p, re.findall(pat, s), re.findall(pat, s, re.ASCII)))
$ ./python repro.py
Nd ['0', '٣'] ['0']
digit ['0', '٣'] ['0']
word ['0', '٣', 'x'] ['0', 'x']
space [' ', '\xa0'] [' ']
White_Space [' ', '\xa0'] [' ']
WSpace [' ', '\xa0'] [' ']
Expected: the \p{property=value} section says which properties the ASCII flag restricts, alongside the existing note that space follows str.isspace and xdigit matches only the ASCII hexadecimal digits.
\p{White_Space} and \p{WSpace} are also absent from the documented list of supported properties, although both are accepted.
Linked PRs
- gh-157699
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
先閱讀 docs.python.org/dev/library/re.html#re.A 中的 re.ASCII 文件,然後閱讀 \p{property=value} 區段及其支援的屬性清單。記錄哪六種屬性寫法受到 ASCII 的限制,並將 White_Space 和 WSpace 加入支援的屬性清單,同時保留現有關於 space 和 xdigit 的註解。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- documentation
- Issue 類型
- 文件
- 難度
- 1/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 30/100