Repository navigation
Materialize code constants through the VM - #8867
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: RustPython/RustPython/.coderabbit.yml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughCode-object conversion now uses the VM to handle bytecode and frozen-code constants. Code-object construction moves from ChangesCode-object creation
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~15 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to No actionable issue remains in the supplied review evidence; this change is ready for normal merge checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The public embedding API requires migration, but inspected construction paths remain separate from code execution. No introduced security weakness was established; external consumers and malformed-input failure containment remain incompletely assessed. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merging this PR will not alter performance
Comparing Footnotes
|
PyObjBag built code object constants from a Context alone, and its
frozenset arm was unimplemented!(), so ctx.new_code() panicked on code
containing a frozenset constant such as `x in {1, 2, 3}`.
IntoCodeObject now takes a VirtualMachine and uses PyVmBag for bytecode
and frozen code objects. Context::new_code, PyObjBag and
AsBag for &Context are removed; callers use VirtualMachine::new_code.
Assisted-by: Claude:claude-opus-5-5
Assisted-by: Grok:grok-4.7
1736c0d to
d2e0200
Compare
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
close #8823
Summary
PyObjBagbuilt code object constants from aContextalone. Its frozenset arm wasunimplemented!(), soctx.new_code()panicked on any code containing a frozenset constant, e.g.x in {1, 2, 3}orfor e in {1, 2, 3}. This affected embedders passing compiled orpy_freeze!code toctx.new_code, asexamples/freezeandexamples/mini_repldo.Every caller already has a
VirtualMachine, andPyVmBagalready builds all constants. This PR routes code object construction through the VM:IntoCodeObject::into_code_objecttakes&VirtualMachineand usesPyVmBagforbytecode::CodeObjectandFrozenCodeObject.Context::new_code,PyObjBagandAsBag for &Contextare removed.VirtualMachine::new_codereplaces them.API change: embedders replace
vm.ctx.new_code(code)withvm.new_code(code).Alternative to #8823, which builds frozensets without a VM.
Tests
vm::interpreter::tests::new_code_materializes_frozenset_constants.cargo build --examples --features freeze-stdlib.-m test test_compile test_code test_frozen test_importlib test_marshal test_dispasses.🤖 Generated with Claude Code
Summary by CodeRabbit