Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta Para iniciantes
#1,213 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@hippi345 já está trabalhando nisso.

Desde 17/10/2026.

  • #1219 de @hippi345 — aberto

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
75/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
java, python
Domínio
backend

Direção de pesquisa

O valor incorreto vem do argumento debug em SysModuleBuiltins.java (por volta da linha 697), que é derivado de PythonOptions.PythonOptimizeFlag. Leia como os outros campos de sys.flags são definidos ali e, em seguida, execute o trecho do relatório para ver sys.flags.debug e subprocess._args_from_interpreter_flags(). Está concluído quando sys.flags.debug é 0 por padrão e nenhum -d é emitido, enquanto optimize e __debug__ permanecem como estão.

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

Descrição

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.

Linguagem predominante
Python
Estrelas
1.7k
Forks
158
Merge médio
8h 15min
PRs com merge (30d)
49

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

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.

Mais de oracle/graalpython

Todas as issues de oracle/graalpython

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

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