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

Method with_builtins

crates/vm/src/scope.rs:23–36  ·  view source on GitHub ↗
(
        locals: Option<ArgMapping>,
        globals: PyDictRef,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

21 }
22
23 pub fn with_builtins(
24 locals: Option<ArgMapping>,
25 globals: PyDictRef,
26 vm: &VirtualMachine,
27 ) -> Self {
28 if !globals.contains_key("__builtins__", vm) {
29 globals
30 .set_item("__builtins__", vm.builtins.clone().into(), vm)
31 .unwrap();
32 }
33 // For module-level code, locals defaults to globals
34 let locals = locals.or_else(|| Some(ArgMapping::from_dict_exact(globals.clone())));
35 Self::new(locals, globals)
36 }
37
38 // pub fn get_locals(&self) -> &Py<PyDict> {
39 // match self.locals.first() {

Callers

nothing calls this directly

Calls 6

newFunction · 0.85
contains_keyMethod · 0.80
SomeClass · 0.50
unwrapMethod · 0.45
set_itemMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected