`re` docs never say that the ASCII flag affects `\p{...}` properties
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con la documentazione di re.ASCII all’indirizzo docs.python.org/dev/library/re.html#re.A, quindi leggi la sezione \p{property=value} e il relativo elenco delle proprietà supportate. Documenta quali sei forme di proprietà sono limitate da ASCII e aggiungi White_Space e WSpace all’elenco delle proprietà supportate, mantenendo le note esistenti su space e xdigit.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 1/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 30/100