python / python/cpython

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

Abierto
#157,698 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

docs
Lenguaje dominante
Python
Estrellas
77.2k
Forks
35.9k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con la documentación de re.ASCII en docs.python.org/dev/library/re.html#re.A y, después, lee la sección \p{property=value} y su lista de propiedades compatibles. Documenta qué seis formas de escribir propiedades están restringidas por ASCII y añade White_Space y WSpace a la lista de propiedades compatibles, conservando las notas existentes sobre space y xdigit.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
documentation
Tipo de issue
Documentación
Dificultad
1/5
Tiempo estimado
1-3 horas
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
30/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.