(&self, obj: Option<PyObjectRef>)
| 146 | } |
| 147 | |
| 148 | pub fn dir(&self, obj: Option<PyObjectRef>) -> PyResult<PyList> { |
| 149 | let seq = match obj { |
| 150 | Some(obj) => self |
| 151 | .get_special_method(&obj, identifier!(self, __dir__))? |
| 152 | .ok_or_else(|| self.new_type_error("object does not provide __dir__"))? |
| 153 | .invoke((), self)?, |
| 154 | None => self.call_method( |
| 155 | self.current_locals()?.as_object(), |
| 156 | identifier!(self, keys).as_str(), |
| 157 | (), |
| 158 | )?, |
| 159 | }; |
| 160 | let items: Vec<_> = seq.try_to_value(self)?; |
| 161 | let lst = PyList::from(items); |
| 162 | lst.sort(Default::default(), self)?; |
| 163 | Ok(lst) |
| 164 | } |
| 165 | |
| 166 | #[inline] |
| 167 | pub(crate) fn get_special_method( |
no test coverage detected