python / python/cpython

`re` docs never say that the ASCII flag affects `\p{...}` properties

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

まだ誰も着手していません。

docs
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Documentation

https://docs.python.org/dev/library/re.html#re.A

The re.ASCII entry lists \w, \W, \b, \B, \d, \D, \s and \S as the constructs it restricts, and the \p{property=value} section never mentions the flags. Six accepted property spellings are restricted by the flag as well, because Nd, digit, word, space, White_Space and WSpace are matched with the same engine categories as \d, \s and \w. The other 52 accepted spellings are unaffected.

$ cat repro.py
import re
s = '0\u0663 \xa0x'
for p in 'Nd', 'digit', 'word', 'space', 'White_Space', 'WSpace':
    pat = r'\p{%s}' % p
    print('%-12s %-18r %r' % (p, re.findall(pat, s), re.findall(pat, s, re.ASCII)))

$ ./python repro.py
Nd           ['0', '٣']         ['0']
digit        ['0', '٣']         ['0']
word         ['0', '٣', 'x']    ['0', 'x']
space        [' ', '\xa0']      [' ']
White_Space  [' ', '\xa0']      [' ']
WSpace       [' ', '\xa0']      [' ']

Expected: the \p{property=value} section says which properties the ASCII flag restricts, alongside the existing note that space follows str.isspace and xdigit matches only the ASCII hexadecimal digits.

\p{White_Space} and \p{WSpace} are also absent from the documented list of supported properties, although both are accepted.

Linked PRs
  • gh-157699

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

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

はじめの一歩

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

調査の方向性

まず docs.python.org/dev/library/re.html#re.A の re.ASCII のドキュメントを読み、次に \p{property=value} セクションと、そこでサポートされているプロパティの一覧を確認します。ASCII によって制限される6つのプロパティ表記を文書化し、White_Space と WSpace をサポートされているプロパティの一覧に追加します。その際、space と xdigit に関する既存の注記は維持してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
documentation
issue の種類
ドキュメント
難易度
1/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
30/100

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

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