Possible `NULL`-related `SystemError` when interpreter is not fully initialized

Abierto
#161,863 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
65/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
c, python
Área
backend

Línea de trabajo

Read Python/import.c around lines 3921–3922 and the IMPORTLIB(interp) definition around lines 95–96 to understand how the null value reaches this path. Reproduce with the _freeze_module command shown in the issue, then check the error handling and tests for this import path. Done means the incomplete initialization case reports a clear SystemError explaining that imports are not fully initialized; the issue also mentions fixing freeze later.

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

Descripción

interpreter-core topic-importlib type-bug

Code: https://github.com/python/cpython/blob/9f386367333f7845095d764fad3ad9b397d04672/Python/import.c#L3921-L3922

Here IMPORTLIB(interp) can be NULL under rare conditions:

https://github.com/python/cpython/blob/9f386367333f7845095d764fad3ad9b397d04672/Python/import.c#L95-L96

For example, when interpreter is not yet fully initialized.

Output:

» ./Programs/_freeze_module crash crash.py crash.h
Exception ignored in the internal traceback machinery:
SystemError: null argument to internal routine
# ...

Refs https://github.com/python/cpython/pull/161860 where I first found this case.
Refs https://github.com/python/cpython/issues/142662 where the initial reproducer was found.

I guess we should raise a different SystemError here with the text that imports are not yet fully initialized.

My proposal is to make the error message better here: it should state the interpreter is not fully initialized.

And ideally we can fix the freeze command as well later.

Lenguaje dominante
Python
Estrellas
78.2k
Forks
36.6k
Merge medio
19 h 57 min
PR fusionados (30 d)
630

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

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.

Más de python/cpython

Todos los issues de python/cpython

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.