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

Function varname_converter

crates/stdlib/src/tkinter.rs:146–167  ·  view source on GitHub ↗
(obj: PyObjectRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

144 }
145
146 fn varname_converter(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult<String> {
147 // if let Ok(bytes) = obj.bytes(vm) {
148 // todo!()
149 // }
150
151 // str
152 if let Some(str) = obj.downcast_ref::<PyStr>() {
153 return Ok(str.as_str().to_string());
154 }
155
156 if let Some(_tcl_obj) = obj.downcast_ref::<TclObject>() {
157 // Assume that the Tcl object has a method to retrieve a string.
158 // return tcl_obj.
159 todo!();
160 }
161
162 // Construct an error message using the type name (truncated to 50 characters).
163 Err(vm.new_type_error(format!(
164 "must be str, bytes or Tcl_Obj, not {:.50}",
165 obj.obj_type().str(vm)?.as_str()
166 )))
167 }
168
169 #[derive(Debug, FromArgs)]
170 struct TkAppGetVarArgs {

Callers 1

inner_getvarMethod · 0.85

Calls 3

to_stringMethod · 0.80
ErrClass · 0.50
as_strMethod · 0.45

Tested by

no test coverage detected