Skip to content

Commit 529d223

Browse files
committed
Add co_cellvars to code object
Closes RustPython#4501
1 parent cf54a78 commit 529d223

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

vm/src/builtins/code.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,18 @@ impl PyRef<PyCode> {
218218
self.code.source_path.to_owned()
219219
}
220220

221+
#[pygetset]
222+
pub fn co_cellvars(self, vm: &VirtualMachine) -> PyTupleRef {
223+
let cellvars = self
224+
.code
225+
.cellvars
226+
.deref()
227+
.iter()
228+
.map(|name| name.to_pyobject(vm))
229+
.collect();
230+
vm.ctx.new_tuple(cellvars)
231+
}
232+
221233
#[pygetset]
222234
fn co_firstlineno(self) -> usize {
223235
self.code.first_line_number

0 commit comments

Comments
 (0)