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

Method inner_getvar

crates/stdlib/src/tkinter.rs:262–303  ·  view source on GitHub ↗
(
            &self,
            args: TkAppGetVarArgs,
            flags: u32,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

260 }
261
262 fn inner_getvar(
263 &self,
264 args: TkAppGetVarArgs,
265 flags: u32,
266 vm: &VirtualMachine,
267 ) -> PyResult<PyObjectRef> {
268 let TkAppGetVarArgs { name, name2 } = args;
269 // TODO: technically not thread safe
270 let name = varname_converter(name, vm)?;
271
272 let name = ffi::CString::new(name).map_err(|e| e.into_pyexception(vm))?;
273 let name2 =
274 ffi::CString::new(name2.unwrap_or_default()).map_err(|e| e.into_pyexception(vm))?;
275 let name2_ptr = if name2.is_empty() {
276 ptr::null()
277 } else {
278 name2.as_ptr()
279 };
280 let res = unsafe {
281 tk_sys::Tcl_GetVar2Ex(
282 self.interpreter,
283 name.as_ptr() as _,
284 name2_ptr as _,
285 flags as _,
286 )
287 };
288 if res.is_null() {
289 // TODO: Should be tk error
290 unsafe {
291 let err_obj = tk_sys::Tcl_GetObjResult(self.interpreter);
292 let err_str_obj = tk_sys::Tcl_GetString(err_obj);
293 let err_cstr = ffi::CStr::from_ptr(err_str_obj as _);
294 return Err(vm.new_type_error(format!("{err_cstr:?}")));
295 }
296 }
297 let res = if self.want_objects {
298 self.tcl_obj_to_pyobject(res, vm)
299 } else {
300 self.unicode_from_object(res, vm)
301 }?;
302 Ok(res)
303 }
304
305 #[pymethod]
306 fn getvar(&self, args: TkAppGetVarArgs, vm: &VirtualMachine) -> PyResult<PyObjectRef> {

Callers 2

getvarMethod · 0.80
globalgetvarMethod · 0.80

Calls 8

varname_converterFunction · 0.85
newFunction · 0.85
tcl_obj_to_pyobjectMethod · 0.80
unicode_from_objectMethod · 0.80
ErrClass · 0.50
into_pyexceptionMethod · 0.45
is_emptyMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected