RecursionError has empty or trailing-space message instead of 'maximum recursion depth exceeded'
@lsahn-gh がすでに取り組んでいます。
2026年7月26日 から。
評価
この issue はまだ評価されていません。
説明
Summary
The RecursionError raised when the recursion guard trips does not carry CPython's message 'maximum recursion depth exceeded'. Depending on which of RustPython's two recursion guards fires first, str(e) is either an empty string or the message with a stray trailing space.
Reproduction
# native C-stack guard (what trips by default, e.g. debug builds)
def f(): f()
try:
f()
except RecursionError as e:
print(repr(str(e)))
# RustPython: ''
# CPython: 'maximum recursion depth exceeded'
# logical depth-limit guard (force it with a low limit)
import sys
sys.setrecursionlimit(60)
def f(): f()
try:
f()
except RecursionError as e:
print(repr(str(e)))
# RustPython: 'maximum recursion depth exceeded ' <- trailing space
# CPython: 'maximum recursion depth exceeded'
CPython always yields exactly 'maximum recursion depth exceeded' (and e.args == ('maximum recursion depth exceeded',)). RustPython yields ('',) or ('maximum recursion depth exceeded ',).
Root cause
crates/vm/src/vm/mod.rs has two guards that construct the RecursionError message inconsistently, and neither matches CPython:
-
Logical depth guard —
check_recursive_call(mod.rs:1877):Err(self.new_recursion_error(format!("maximum recursion depth exceeded {_where}")))With the common
_where == ""this produces a trailing space:"maximum recursion depth exceeded ". -
Native C-stack guard —
with_recursion(mod.rs:1692) andresume_gen_frame(mod.rs:1767):return Err(self.new_recursion_error(_where.to_string())); // 1692, _where == "" for normal calls return Err(self.new_recursion_error(String::new())); // 1767Here
_whereis used as the whole message, so a normal call (empty_where) yields an empty message.
The two functions disagree on whether _where is a suffix appended to "maximum recursion depth exceeded" or the entire message. The fix is to make both paths produce "maximum recursion depth exceeded" (optionally + " while {context}" when context is present, with no trailing space when it is absent).
Reference
Verified against CPython 3.14.5.
Investigated and drafted by Claude; reviewed before filing.
- 主要言語
- Rust
- スター
- 22.4k
- フォーク
- 1.5k
- 平均マージ
- 15時間 18分
- マージ済み PR(30日)
- 172
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
RustPython/RustPython のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
RustPython/RustPython#8470 · コメント 2 件 ·
-
C-bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
RustPython/RustPython#7995 · コメント 5 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
RustPython/RustPython#5577 ·
-
C-bug
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
RustPython/RustPython#8685 · コメント 7 件 · リアクション 1 件 ·
-
C-compat
RustPython/RustPython#8496 · コメント 1 件 · 担当者 1 名 ·
RustPython/RustPython の issue をすべて見る
似ている issue
-
risk:low runtime status:in-progress type:test
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
zeroclaw-labs/zeroclaw#11023 ·
-
good first issue refactor
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
bevyengine/bevy#25861 ·