MCPcopy Index your code
hub / github.com/RustPython/RustPython / repr_file_obj_name

Function repr_file_obj_name

crates/vm/src/stdlib/_io.rs:1544–1568  ·  view source on GitHub ↗
(obj: &PyObject, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

1542 }
1543
1544 pub fn repr_file_obj_name(obj: &PyObject, vm: &VirtualMachine) -> PyResult<Option<PyStrRef>> {
1545 let name = match obj.get_attr("name", vm) {
1546 Ok(name) => Some(name),
1547 Err(e)
1548 if e.fast_isinstance(vm.ctx.exceptions.attribute_error)
1549 || e.fast_isinstance(vm.ctx.exceptions.value_error) =>
1550 {
1551 None
1552 }
1553 Err(e) => return Err(e),
1554 };
1555 match name {
1556 Some(name) => {
1557 if let Some(_guard) = ReprGuard::enter(vm, obj) {
1558 name.repr(vm).map(Some)
1559 } else {
1560 Err(vm.new_runtime_error(format!(
1561 "reentrant call inside {}.__repr__",
1562 obj.class().slot_name()
1563 )))
1564 }
1565 }
1566 None => Ok(None),
1567 }
1568 }
1569
1570 #[pyclass]
1571 trait BufferedMixin: PyPayload + StaticType {

Callers 2

slot_reprMethod · 0.85
repr_strMethod · 0.85

Calls 6

fast_isinstanceMethod · 0.80
SomeClass · 0.50
ErrClass · 0.50
get_attrMethod · 0.45
mapMethod · 0.45
reprMethod · 0.45

Tested by

no test coverage detected