Add co_freevars to code object

This commit is contained in:
minh.pham2000
2023-02-16 10:10:15 +07:00
parent 1fd557d549
commit 07f4218bf4

View File

@@ -262,6 +262,17 @@ impl PyRef<PyCode> {
vm.ctx.new_tuple(varnames)
}
#[pygetset]
pub fn co_freevars(self, vm: &VirtualMachine) -> PyTupleRef {
let names = self.code
.freevars
.deref()
.iter()
.map(|name| name.to_pyobject(vm))
.collect();
vm.ctx.new_tuple(names)
}
#[pymethod]
pub fn replace(self, args: ReplaceArgs, vm: &VirtualMachine) -> PyResult<PyCode> {
let posonlyarg_count = match args.co_posonlyargcount {