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

Method repr_wtf8

crates/stdlib/src/_asyncio.rs:1914–1937  ·  view source on GitHub ↗
(zelf: &Py<Self>, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

1912
1913 impl Representable for PyTask {
1914 fn repr_wtf8(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<Wtf8Buf> {
1915 let class_name = zelf.class().name().to_string();
1916
1917 if let Some(_guard) = ReprGuard::enter(vm, zelf.as_object()) {
1918 // Try to use _task_repr_info if available
1919 if let Ok(info) = get_task_repr_info(zelf.as_object(), vm)
1920 && info.as_bytes() != b"state=unknown"
1921 {
1922 return Ok(wtf8_concat!("<", class_name, " ", info, ">"));
1923 }
1924
1925 // Fallback: build repr from task properties directly
1926 let state = zelf.base.fut_state.load().as_str().to_lowercase();
1927 let name = zelf.task_name.read().as_ref().and_then(|n| n.str(vm).ok());
1928 let coro_repr = zelf.task_coro.read().as_ref().and_then(|c| c.repr(vm).ok());
1929 let name = name.as_ref().map_or("?".as_ref(), |s| s.as_wtf8());
1930 let coro_repr = coro_repr.as_ref().map_or("?".as_ref(), |s| s.as_wtf8());
1931 Ok(wtf8_concat!(
1932 "<", class_name, " ", state, " name='", name, "' coro=", coro_repr, ">"
1933 ))
1934 } else {
1935 Ok(Wtf8Buf::from(format!("<{class_name} ...>")))
1936 }
1937 }
1938 }
1939
1940 impl Iterable for PyTask {

Callers

nothing calls this directly

Calls 15

get_task_repr_infoFunction · 0.85
to_stringMethod · 0.80
to_lowercaseMethod · 0.80
okMethod · 0.80
nameMethod · 0.45
classMethod · 0.45
as_objectMethod · 0.45
as_bytesMethod · 0.45
as_strMethod · 0.45
loadMethod · 0.45
as_refMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected