python / python/cpython

`\p{...}` names ignore only spaces, though the docs promise whitespace

Aperta
#156,185 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

@serhiy-storchaka ci sta già lavorando.

Dal 21/8/2026.

3.16 stdlib 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:

Doc/library/re.rst says of the \p{property=value} escape: "Property and value names are matched loosely: case, whitespace, '-' and '_' are ignored." _normalize() in Lib/re/_properties.py removes only U+0020, so a property or value name spelled with a tab, newline, carriage return, vertical tab or form feed is rejected.

import re

for name in ['L u', 'L\tu']:
    try:
        re.compile(r'\p{%s}' % name)
        print(repr(name), 'accepted')
    except re.PatternError as e:
        print(repr(name), 'rejected:', e.msg)
'L u' accepted
'L\tu' rejected: unknown property name 'L\tu'

Expected: both accepted, since the documentation says whitespace is ignored. UAX #44 UAX44-LM3, cited by _normalize()'s own comment, says to ignore whitespace rather than spaces.

Either side can change: narrow the documentation to "spaces", or strip \t\n\v\f\r in _normalize() to match UAX44-LM3. \p{...} is new in 3.16 and has not shipped, and the only user-visible effect either way is which spellings raise PatternError at compile time.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs
  • gh-156304

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.