python / python/cpython

`\p{...}` gives wrong results when mixed with letters under `re.IGNORECASE`

Offen
#155,297 1 Kommentar 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@serhiy-storchaka arbeitet bereits daran.

Seit 07.8.2026.

extension-modules topic-regex type-bug
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
35.9k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.