(&self, vm: &VirtualMachine)
| 373 | } |
| 374 | |
| 375 | pub fn ascii(&self, vm: &VirtualMachine) -> PyResult<PyRef<PyStr>> { |
| 376 | let repr = self.repr(vm)?; |
| 377 | if repr.as_wtf8().is_ascii() { |
| 378 | Ok(repr) |
| 379 | } else { |
| 380 | Ok(vm.ctx.new_str(to_ascii(repr.as_wtf8()))) |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | pub fn str_utf8(&self, vm: &VirtualMachine) -> PyResult<PyRef<PyUtf8Str>> { |
| 385 | self.str(vm)?.try_into_utf8(vm) |