mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 12:00:18 +00:00
...
This commit is contained in:
parent
2689e16bb6
commit
b73029247b
@ -439,7 +439,7 @@ __NEXT_STEP:;
|
|||||||
source = it->second;
|
source = it->second;
|
||||||
_lazy_modules.erase(it);
|
_lazy_modules.erase(it);
|
||||||
}
|
}
|
||||||
CodeObject_ code = compile(source, name.sv(), EXEC_MODE);
|
CodeObject_ code = compile(source, Str(name.sv())+".py", EXEC_MODE);
|
||||||
PyObject* new_mod = new_module(name);
|
PyObject* new_mod = new_module(name);
|
||||||
_exec(code, new_mod);
|
_exec(code, new_mod);
|
||||||
new_mod->attr()._try_perfect_rehash();
|
new_mod->attr()._try_perfect_rehash();
|
||||||
|
@ -190,6 +190,15 @@ inline void init_builtins(VM* _vm) {
|
|||||||
return VAR(ss.str());
|
return VAR(ss.str());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
_vm->bind_method<1>("object", "__getattribute__", [](VM* vm, ArgsView args) {
|
||||||
|
PyObject* self = args[0];
|
||||||
|
if(is_tagged(self) || !self->is_attr_valid()) vm->TypeError("object has no attribute");
|
||||||
|
StrName name = CAST(Str&, args[1]);
|
||||||
|
PyObject* ret = self->attr().try_get(name);
|
||||||
|
if(ret == nullptr) vm->AttributeError(name.sv());
|
||||||
|
return ret;
|
||||||
|
});
|
||||||
|
|
||||||
_vm->bind_method<1>("object", "__eq__", CPP_LAMBDA(VAR(args[0] == args[1])));
|
_vm->bind_method<1>("object", "__eq__", CPP_LAMBDA(VAR(args[0] == args[1])));
|
||||||
_vm->bind_method<1>("object", "__ne__", CPP_LAMBDA(VAR(args[0] != args[1])));
|
_vm->bind_method<1>("object", "__ne__", CPP_LAMBDA(VAR(args[0] != args[1])));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user