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

Function get_task_repr_info

crates/stdlib/src/_asyncio.rs:911–939  ·  view source on GitHub ↗
(task: &PyObject, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

909 }
910
911 fn get_task_repr_info(task: &PyObject, vm: &VirtualMachine) -> PyResult<Wtf8Buf> {
912 // vm.import returns the top-level module, get base_tasks submodule
913 match vm
914 .import("asyncio.base_tasks", 0)
915 .and_then(|asyncio| asyncio.get_attr(vm.ctx.intern_str("base_tasks"), vm))
916 {
917 Ok(base_tasks) => {
918 match vm.get_attribute_opt(base_tasks, vm.ctx.intern_str("_task_repr_info")) {
919 Ok(Some(func)) => {
920 let info: PyObjectRef = func.call((task.to_owned(),), vm)?;
921 let list: PyListRef = info.downcast().map_err(|_| {
922 vm.new_type_error("_task_repr_info should return a list")
923 })?;
924 let mut result = Wtf8Buf::new();
925 let parts = list.borrow_vec();
926 for (i, x) in parts.iter().enumerate() {
927 if i > 0 {
928 result.push_str(" ");
929 }
930 result.push_wtf8(x.str(vm)?.as_wtf8());
931 }
932 Ok(result)
933 }
934 _ => get_future_repr_info(task, vm),
935 }
936 }
937 Err(_) => get_future_repr_info(task, vm),
938 }
939 }
940
941 #[pyattr]
942 #[pyclass(name = "FutureIter", module = "_asyncio", traverse)]

Callers 1

repr_wtf8Method · 0.85

Calls 15

newFunction · 0.85
get_future_repr_infoFunction · 0.85
intern_strMethod · 0.80
get_attribute_optMethod · 0.80
downcastMethod · 0.80
borrow_vecMethod · 0.80
push_wtf8Method · 0.80
importMethod · 0.45
get_attrMethod · 0.45
callMethod · 0.45
to_ownedMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected