Other consequences of textwrap.wrap() changes in 3.15
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 77.2k
- Forks
- 36k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
Bug report
Bug description:
It seems like the change in #139902 had other effects than what the PR intended. If those changes are intentional, it would be good if they were documented. And if they were not intentional, then this seem like a bug. This change has since been backported (#139902, #139903), though I don't believe those backports have been released.
Given the following code:
import textwrap
textwrap.wrap(' ABCDEFG', width=1)
In 3.14.0, this returns [' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G']
In 3.15.0a1, this returns ['A', 'B', 'C', 'D', 'E', 'F', 'G']
Since the PR only mentions trailing whitespace, it appears this change was unintended.
The documentation reads as follows.
drop_whitespace
(default: True) If true, whitespace at the beginning and ending of every line (after wrapping but before indenting) is dropped. Whitespace at the beginning of the paragraph, however, is not dropped if non-whitespace follows it. If whitespace being dropped takes up an entire line, the whole line is dropped.
I am not sure how to interpret this. This line would seem to indicate the space should be preserved.
Whitespace at the beginning of the paragraph, however, is not dropped if non-whitespace follows it.
CPython versions tested on:
3.15
Operating systems tested on:
Linux
Linked PRs
- gh-140639
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza ejecutando el ejemplo textwrap.wrap(' ABCDEFG', width=1) en las versiones de Python indicadas y leyendo el comportamiento documentado de drop_whitespace. Compara las consecuencias del issue #139902 con el PR vinculado #140639; el trabajo estará terminado cuando se haya resuelto si el comportamiento cambiado de los espacios iniciales es intencionado y se haya corregido o documentado en consecuencia.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- backend
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 30/100