Other consequences of textwrap.wrap() changes in 3.15
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 77.2k
- Forks
- 36k
- Métricas de merge de PRs
- Métricas de PR pendentes
Descrição
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
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece executando o exemplo textwrap.wrap(' ABCDEFG', width=1) nas versões do Python mencionadas e lendo o comportamento documentado de drop_whitespace. Compare as consequências do issue #139902 com o PR vinculado #140639; o trabalho estará concluído quando for resolvido se o comportamento alterado do espaço inicial é intencional e ele for corrigido ou documentado adequadamente.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- python
- Domínio
- backend
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 30/100