python / python/cpython

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

Abierto
#140,456 2 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

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

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

Reproduce el script proporcionado con Python 3.12 y 3.13, y empieza después por traceback.format_list(). Revisa el PR vinculado gh-153469 y el comportamiento circundante de traceback antes de decidir si se pretende compatibilidad o documentación. Se considera terminado cuando el comportamiento aceptado esté implementado o documentado y el caso multilínea esté cubierto por las pruebas pertinentes.

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

Evaluación

Stack tecnológico
python
Área
tooling
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.