Get the module of the caller frame, similar to CPython's caller() function. Returns the module name or None if not found. Note: CPython's implementation (in typevarobject.c) gets the module from the frame's function object using PyFunction_GetModule(f->f_funcobj). However, RustPython's Frame doesn't store a reference to the function object, so we get the module name from the frame's globals dicti
(vm: &VirtualMachine)
| 50 | /// RustPython's Frame doesn't store a reference to the function object, so we |
| 51 | /// get the module name from the frame's globals dictionary instead. |
| 52 | fn caller(vm: &VirtualMachine) -> Option<PyObjectRef> { |
| 53 | let frame = vm.current_frame()?; |
| 54 | |
| 55 | // In RustPython, we get the module name from frame's globals |
| 56 | // This is similar to CPython's sys._getframe().f_globals.get('__name__') |
| 57 | frame.globals.get_item("__name__", vm).ok() |
| 58 | } |
| 59 | |
| 60 | /// Set __module__ attribute for an object based on the caller's module. |
| 61 | /// This follows CPython's behavior for TypeVar and similar objects. |
no test coverage detected