| 159 | |
| 160 | #[pyfunction] |
| 161 | fn get_objects(args: GetObjectsArgs, vm: &VirtualMachine) -> PyResult<PyListRef> { |
| 162 | let generation_opt = args.generation.flatten(); |
| 163 | if let Some(g) = generation_opt |
| 164 | && !(0..=2).contains(&g) |
| 165 | { |
| 166 | return Err(vm.new_value_error(format!("generation must be in range(0, 3), not {}", g))); |
| 167 | } |
| 168 | let objects = gc_state::gc_state().get_objects(generation_opt); |
| 169 | Ok(vm.ctx.new_list(objects)) |
| 170 | } |
| 171 | |
| 172 | /// Return the list of objects directly referred to by any of the arguments. |
| 173 | #[pyfunction] |