`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