| 298 | |
| 299 | #[pymethod] |
| 300 | fn __dir__(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<Vec<PyObjectRef>> { |
| 301 | // First check if __dict__ attribute exists and is actually a dictionary |
| 302 | let dict_attr = zelf.as_object().get_attr(identifier!(vm, __dict__), vm)?; |
| 303 | let dict = dict_attr |
| 304 | .downcast::<PyDict>() |
| 305 | .map_err(|_| vm.new_type_error("<module>.__dict__ is not a dictionary"))?; |
| 306 | let attrs = dict.into_iter().map(|(k, _v)| k).collect(); |
| 307 | Ok(attrs) |
| 308 | } |
| 309 | |
| 310 | #[pygetset] |
| 311 | fn __annotate__(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<PyObjectRef> { |