python / python/cpython

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

Aberta
#156,185 1 comentário 0 reações 1 responsável Ver no GitHub

@serhiy-storchaka já está trabalhando nisso.

Desde 21/8/2026.

3.16 stdlib topic-regex type-bug
Linguagem predominante
Python
Estrelas
77.2k
Forks
36k
Métricas de merge de PRs
Métricas de PR pendentes

Descrição

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

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.