mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Merge pull request #4509 from minhrongcon2000/fix/add_co_freevars
Add co_freevars to code object
This commit is contained in:
@@ -262,6 +262,18 @@ 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 {
|
||||
|
||||
Reference in New Issue
Block a user