Skip to content

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

Open

Description

@fedonman

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

Activity

  1. added
    docsDocumentation in the Doc dir
    on Sep 18, 2026
  2. LestlinRobins commented on Sep 30, 2026

    @LestlinRobins

    @aisk Could I work on this? Can you please assign this to me?

  3. aisk commented on Oct 1, 2026

    @aisk
    Member

    @aisk Could I work on this? Can you please assign this to me?

    Hi, there is already an active PR for this issue opened by the reporter, so please find another one if you want to contribute.

    Also, we usually don't assign issues to people. If the solution to an issue is clear and no one is working on it, you can just open a PR.

  4. LestlinRobins commented on Oct 1, 2026

    @LestlinRobins

    @aisk Could I work on this? Can you please assign this to me?

    Hi, there is already an active PR for this issue opened by the reporter, so please find another one if you want to contribute.

    Also, we usually don't assign issues to people. If the solution to an issue is clear and no one is working on it, you can just open a PR.

    Ohh alright. Got it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions