python / python/cpython

Regression: 3.13 `traceback.format_list()` breaking behavior change.

Aberta
#140,456 2 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

docs
Linguagem predominante
Python
Estrelas
77.2k
Forks
35.9k
Métricas de merge de PRs
Métricas de PR pendentes

Descrição

Bug report

Bug description:

traceback.format_list() no longer works with lines that have breaks in them:

import traceback
import sys

print(f"Python {sys.version_info.major}.{sys.version_info.minor}")

# Frame with multiline text (source + variable annotations)
frames = [('test.py', 10, 'func', 'x = foo + bar\n\t\thello\n\tworld')]

print("\nInput (3 lines):")
print(repr(frames[0][3]))

print("\nOutput from traceback.format_list():")
result = traceback.format_list(frames)[0] # Yes, it't always a 1-element list both on 3.12 adn 3.13.
print(result)
Python 3.12

Input (3 lines):
'x = foo + bar\n\t\thello\n\tworld'

Output from traceback.format_list():
  File "test.py", line 10, in func
    x = foo + bar
                hello
        world
Python 3.13

Input (3 lines):
'x = foo + bar\n\t\thello\n\tworld'

Output from traceback.format_list():
  File "test.py", line 10, in func
    x = foo + bar

This broke bettre_exceptions on 3.13, which was fixed by formatting the traceback manually. Can we either

  • Revert to old behavior in 3.15 and maybe document that it was broken in 3.13 and 3.14?
  • Document the behavior change?

ref: https://github.com/Qix-/better-exceptions/issues/134

CPython versions tested on:

3.13

Operating systems tested on:

No response

Linked PRs
  • gh-153469

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Reproduza o script fornecido com Python 3.12 e 3.13 e, em seguida, comece por traceback.format_list(). Revise o PR vinculado gh-153469 e o comportamento circundante de traceback antes de decidir se o objetivo é compatibilidade ou documentação. Está concluído quando o comportamento aceito estiver implementado ou documentado e o caso de múltiplas linhas estiver coberto pelos testes relevantes.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
python
Domínio
tooling
Tipo de issue
Bug
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.