Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[Bug]: sys.flags.debug is 1 whenever optimization is off

Abierto Apto para principiantes
#1,213 0 comentarios 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
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
75/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
java, python
Área
backend

Línea de trabajo

El valor incorrecto proviene del argumento debug en SysModuleBuiltins.java (alrededor de la línea 697), que se deriva de PythonOptions.PythonOptimizeFlag. Lee cómo se establecen los demás campos de sys.flags allí, luego ejecuta el fragmento del reporte para ver sys.flags.debug y subprocess._args_from_interpreter_flags(). Está terminado cuando sys.flags.debug es 0 por defecto y no se emite ningún -d, mientras que optimize y __debug__ se mantienen como están.

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

Descripción

Describe the bug

sys.flags.debug is 1 whenever optimization is off. In CPython it is 0 unless the interpreter was started with -d (parser debug output), regardless of -O.

sys.flags is built in SysModuleBuiltins with debug derived from the optimize option:

https://github.com/oracle/graalpython/blob/63022137a797dc10251acac5460bb2e5b0a113cb/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java#L697

PInt.intValue(!language.getEngineOption(PythonOptions.PythonOptimizeFlag)), // debug

This looks like debug being conflated with __debug__.

The visible effect: subprocess._args_from_interpreter_flags() emits -d for every non-optimized run, so anything that re-executes sys.executable with the current interpreter flags passes -d. The most common case is multiprocessing with the spawn start method. An embedder whose python.Executable does not accept -d then fails to start the child, and the parent gets EOFError from Connection.recv().

Operating system

Linux

CPU architecture

x86_64

GraalPy version

25.x, embedded through the polyglot API. The line above is unchanged on current master.

JDK version

GraalVM JDK 25

Context configuration

Default options; python.PythonOptimizeFlag not set.

Steps to reproduce
import sys, subprocess
print(sys.flags.debug, sys.flags.optimize, __debug__)
print(subprocess._args_from_interpreter_flags())
Expected behavior

As on CPython 3.12 with no flags:

0 0 True
[]

Actual:

1 0 True
['-d']

(plus whatever other flags are configured).

Stack trace

None. The symptom shows up downstream, e.g. a spawned multiprocessing child exits during argument parsing and the parent raises EOFError.

Additional context

A fix would be to report debug as 0 (GraalPy has no -d equivalent), or to back it with a dedicated option if one is wanted. optimize and __debug__ are already correct.

Lenguaje dominante
Python
Estrellas
1.7k
Forks
158
Merge medio
9 h 12 min
PR fusionados (30 d)
50

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 oracle/graalpython

Todos los issues de oracle/graalpython

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.