Repository navigation
fix(python): lift the ~95-call cap and stop echoing the final value - #2832
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 739ac73 | Commit Preview URL Branch Preview URL |
Nov 05 2026, 03:55 AM |
Review verdict: approve-worthy, no findingsThis PR fixes two real bugs in the Python builtin and the fix approach is sound. Charging actual Monty heap high-water ( Findings: none — no P0/P1/P2. Ordering in Context read beyond the diff: Update on latest push (head Not reviewed: nothing material. Diff reported |
…ng the final value Each embedded python3 call reserved max_memory/64 work units up front (1M at the 64 MiB default) out of the 100M budget, so the 96th call in a script failed even for `pass`. Charge Monty heap growth past the run's high-water mark instead; repeated large runs still share one budget. Monty converts the module's final value to a host object outside its memory and time limits, so a shared list graph as the last expression (x = [x, x] thirty times) expanded to 2^30 leaves and hung past the timeout. End every program with a None statement and drop the REPL-style echo, matching CPython for -c, files and stdin.
a141233 to
739ac73
Compare
Requested by Михайло · project thread
What changed
python3(Monty) can be called as often as a script likes. Each call now pays the shared work budget for the heap it actually uses (one unit per 64 bytes past the run's high-water mark) instead of reservingmax_memory / 64units up front. Repeated large runs still share one budget (TM-DOS-096 holds: the regression test now uses two 12 MiB runs against a ~19 MiB budget).python3 -c "2 + 2"prints nothing, like CPython for-c, files and stdin). Every program ends with aNonestatement so Monty's final value is alwaysNone.Why
Found reviewing a downstream integration (harnx), reproduced on 0.20.3:
python3 -c passin one script failed withwork units exhausted.x = [x, x]thirty times as the last line expands to 2^30 leaves (~500 MiB) and ignores the timeout. Bashkit can't bound that conversion, so it must never happen.Before / After
Before:
After: 300 calls in one script succeed (
many_small_invocations_fit_in_one_script); the shared-graph program exits 0 immediately (test_large_shared_final_value_finishes); a heavy-memory loop still exhausts a small budget (memory_used_is_charged_to_the_work_budget, verified failing with the charge removed).Risk
python.md, knowledge) now say to useprint(). Code ending in a trailing backslash is left unmodified so it stays a SyntaxError.Checklist
Generated by Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.