`re` docs never say that the ASCII flag affects `\p{...}` properties
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the re.ASCII documentation at docs.python.org/dev/library/re.html#re.A, then read the \p{property=value} section and its supported-property list. Document which six property spellings are restricted by ASCII and add White_Space and WSpace to the supported list, while preserving the existing notes about space and xdigit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 30/100