`\p{...}` gives wrong results when mixed with letters under `re.IGNORECASE`
Aperta
@serhiy-storchaka ci sta già lavorando.
Dal 7/8/2026.
extension-modules
topic-regex
type-bug
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Bug description:
\p{Lu} matches uppercase Unicode letters. It breaks when mixed with a standard letter with re.IGNORECASE:
import re
property_only = re.compile(r"[\p{Lu}]", re.IGNORECASE)
property_plus_one = re.compile(r"[\p{Lu}1]", re.IGNORECASE)
property_plus_a = re.compile(r"[\p{Lu}a]", re.IGNORECASE)
assert property_only.fullmatch("B")
assert property_plus_one.fullmatch("B")
assert property_plus_a.fullmatch("B"), "adding 'a' broke the match for 'B'"
Expected: adding "a" to the character class shouldn't break the existing match
Actual: AssertionError: adding 'a' broke the match for 'B'
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
- gh-155299
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.
Valutazione
Questa issue non è ancora stata valutata.