python / python/cpython

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

オープン
#156,185 コメント 1 件 リアクション 0 件 担当者 1 名 GitHub で見る

@serhiy-storchaka がすでに取り組んでいます。

2026年8月21日 から。

3.16 stdlib topic-regex type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。