Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Offen Anfängerfreundlich
#1,213 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
75/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
java, python
Bereich
backend

Rechercherichtung

Der falsche Wert stammt vom Argument debug in SysModuleBuiltins.java (etwa Zeile 697), das aus PythonOptions.PythonOptimizeFlag abgeleitet wird. Lies nach, wie die anderen Felder von sys.flags dort gesetzt werden, und führe dann das Snippet aus dem Report aus, um sys.flags.debug und subprocess._args_from_interpreter_flags() zu sehen. Fertig ist es, wenn sys.flags.debug standardmäßig 0 ist und kein -d ausgegeben wird, während optimize und __debug__ unverändert bleiben.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
Python
Sterne
1.7k
Forks
158
Ø Merge
8 Std. 31 Min.
Gemergte PRs (30 T.)
55

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus oracle/graalpython

Alle Issues in oracle/graalpython

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.