I'm pretty sure WeakRefList needs to be a side-table ala ObjC, or else it can be deallocated while the destructor is still running, but after you've grabbed the pointer.
@coolreader18 I'm trying to implements "Parenthesized context managers(bpo-12782)" before adding RustPython/RustPython#3427 but stuck in lalrpop..
What I'm trying to add is just support parenthesizing with context like below which is illegal in before.
with (
manager() as x,
manager() as y
):
passBut I'm struggling with shift-reduce conflict 😢
Could you take a look and advice these lines
Corresponding parts Python.gram in cpython are these lines
I'm using the rustpython-vm crate in order to run some python code from a rust application.
Currently I'm having issues with first compiling a python library, loading it into a module and after that calling functions from that module in a later call to the VM.
I'm using the import_file function to create the module, but I'm not sure how to later create a scope for the VM that includes this module.
Does anyone know how I could go about debugging this?
use rustpython_vm::compile::Mode;
use rustpython_vm::Interpreter;
use rustpython_vm::import::import_file;
use rustpython_vm::compile;
fn main() {
Interpreter::default().enter(|vm| {
let imp = import_file(vm, "mylib", "mylib".to_owned(), MAIN.to_owned()).unwrap();
//let import = vm.compile(MAIN, compile::Mode::Exec, "<main>".to_owned())
// .map_err(|err| vm.new_syntax_error(&err)).unwrap();
let scope = vm.new_scope_with_builtins();
let code_obj = vm
.compile(
r#"import * from mylib
def initt():
print("fef")
init()"#,
Mode::Exec,
"<embedded>".to_owned(),
)
.map_err(|err| vm.new_syntax_error(&err))
.unwrap();
//vm.run_code_obj(import, scope).unwrap();
vm.run_code_obj(code_obj, scope).unwrap();
});
println!("Hello, rust!");
}
const MAIN: &str = r#"print("PYTHON MODULE INIT")
def init():
print("Python says init")
def run(command, ext_state, state):
print("Python says run")
"#;
code_obj run in a scope that includes imp
RUST_BACKTRACE=1 and the result was the same
RUST_BACKTRACE=1 cargo [..]