python / python/cpython

`test_warnings` not restoring filters for free threading tests

Abierto
#155,608 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

tests topic-free-threading type-bug
Lenguaje dominante
Python
Estrellas
77.2k
Forks
35.9k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

Bug description:
PYTHONWARNINGS=default ./python.exe -W default -m test test_warnings
Using random seed: 2934466897
0:00:00 load avg: 8.99 mem: 287.4 MiB Run 1 test sequentially in a single process
0:00:00 load avg: 8.99 mem: 287.4 MiB [1/1] test_warnings
Warning -- warnings.filters was modified by test_warnings
Warning --   Before: (12918522352, [('default', None, <class 'Warning'>, None, 0)], [('default', None, <class 'Warning'>, None, 0)])
Warning --   After:  (12918522352, [('default', None, <class 'Warning'>, None, 0)], []) 
0:00:20 load avg: 7.32 mem: 392.4 MiB [1/1/1] test_warnings failed (env changed)

This appears to race because the setUp is calling resetwarnings without getting it's own context.

This does not appear on the Cpython CI since --py-debug is used I believe which starts the warnings filter by default as an empty list so less likely to race, this occurred to me when running cpython tests against a release build and this test would not work.

The root cause I think is due to regr test asserting that the env hasn't been changed, however due to starting the test with warnings that are cleared this does not hold true

CPython versions tested on:

CPython main branch

Operating systems tested on:

Macos

Linked PRs
  • gh-155609

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

Empieza ejecutando PYTHONWARNINGS=default ./python.exe -W default -m test test_warnings y examina la configuración de test_warnings alrededor de resetwarnings. Comprueba cómo la prueba de regresión compara el entorno de advertencias antes y después; se considera terminado cuando la prueba restaura sus filtros y el comando deja de informar de un cambio en el entorno.

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

Evaluación

Stack tecnológico
python
Área
testing-qa
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.