Skip to content

Commit cf0ee0c

Browse files
committed
Add co_names to PyCode
1 parent ac25328 commit cf0ee0c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

vm/src/builtins/code.rs

+12
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,18 @@ impl PyRef<PyCode> {
215215
self.code.obj_name.to_owned()
216216
}
217217

218+
#[pygetset]
219+
fn co_names(self, vm: &VirtualMachine) -> PyTupleRef {
220+
let names = self
221+
.code
222+
.names
223+
.deref()
224+
.iter()
225+
.map(|name| name.to_pyobject(vm))
226+
.collect();
227+
vm.ctx.new_tuple(names)
228+
}
229+
218230
#[pygetset]
219231
fn co_flags(self) -> u16 {
220232
self.code.flags.bits()

0 commit comments

Comments
 (0)