mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
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
22 lines
522 B
Rust
22 lines
522 B
Rust
use rustpython_vm as vm;
|
|
|
|
fn main() -> vm::PyResult<()> {
|
|
vm::Interpreter::without_stdlib(Default::default()).enter(run)
|
|
}
|
|
|
|
#[expect(clippy::unnecessary_wraps)]
|
|
fn run(vm: &vm::VirtualMachine) -> vm::PyResult<()> {
|
|
let scope = vm.new_scope_with_builtins();
|
|
|
|
// the file parameter is relative to the current file.
|
|
let module = vm::py_compile!(file = "freeze.py");
|
|
|
|
let res = vm.run_code_obj(vm.new_code(module), scope);
|
|
|
|
if let Err(exc) = res {
|
|
vm.print_exception(&exc);
|
|
}
|
|
|
|
Ok(())
|
|
}
|