Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン 初心者向け
#1,213 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
75/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java, python
領域
backend

調査の方向性

誤った値は SysModuleBuiltins.java(697行目付近)の debug 引数から来ており、これは PythonOptions.PythonOptimizeFlag から導出されています。そこで sys.flags の他のフィールドがどのように設定されているかを読み、そのうえでレポートのスニペットを実行して sys.flags.debug と subprocess._args_from_interpreter_flags() を確認してください。sys.flags.debug がデフォルトで 0 になり、-d が出力されなくなり、optimize と __debug__ は現状のままであれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
1.7k
フォーク
158
平均マージ
8時間 31分
マージ済み PR(30日)
55

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

oracle/graalpython のほかの issue

oracle/graalpython の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。