mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 12:00:18 +00:00
skip kwargc check on -1
This commit is contained in:
parent
57b4595c11
commit
bdece9e80c
@ -140,7 +140,6 @@ struct NativeFunc {
|
|||||||
NativeFunc(NativeFuncC f, FuncDecl_ decl, any userdata={}): f(f), argc(-1), decl(decl), _userdata(std::move(userdata)) {}
|
NativeFunc(NativeFuncC f, FuncDecl_ decl, any userdata={}): f(f), argc(-1), decl(decl), _userdata(std::move(userdata)) {}
|
||||||
|
|
||||||
PyVar call(VM* vm, ArgsView args) const { return f(vm, args); }
|
PyVar call(VM* vm, ArgsView args) const { return f(vm, args); }
|
||||||
void check_size(VM* vm, ArgsView args) const;
|
|
||||||
void _gc_mark(VM*) const;
|
void _gc_mark(VM*) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
13
src/vm.cpp
13
src/vm.cpp
@ -1123,8 +1123,12 @@ PyVar VM::vectorcall(int ARGC, int KWARGC, bool op_call){
|
|||||||
for(int j=0; j<co_nlocals; j++) _base[j] = __vectorcall_buffer[j];
|
for(int j=0; j<co_nlocals; j++) _base[j] = __vectorcall_buffer[j];
|
||||||
ret = f.call(vm, ArgsView(s_data._sp - co_nlocals, s_data._sp));
|
ret = f.call(vm, ArgsView(s_data._sp - co_nlocals, s_data._sp));
|
||||||
}else{
|
}else{
|
||||||
if(KWARGC != 0) TypeError("old-style native_func does not accept keyword arguments");
|
if(f.argc != -1) {
|
||||||
f.check_size(this, args);
|
if(KWARGC != 0) TypeError("old-style native_func does not accept keyword arguments. If you want to skip this check, specify `argc` to -1");
|
||||||
|
if(args.size() != f.argc){
|
||||||
|
vm->TypeError(_S("expected ", f.argc, " arguments, got ", args.size()));
|
||||||
|
}
|
||||||
|
}
|
||||||
ret = f.call(this, args);
|
ret = f.call(this, args);
|
||||||
}
|
}
|
||||||
s_data.reset(p0);
|
s_data.reset(p0);
|
||||||
@ -1619,11 +1623,6 @@ void Dict::_probe_1(VM* vm, PyVar key, bool &ok, int &i) const{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeFunc::check_size(VM* vm, ArgsView args) const{
|
|
||||||
if(args.size() != argc && argc != -1) {
|
|
||||||
vm->TypeError(_S("expected ", argc, " arguments, got ", args.size()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if PK_ENABLE_PROFILER
|
#if PK_ENABLE_PROFILER
|
||||||
void NextBreakpoint::_step(VM* vm){
|
void NextBreakpoint::_step(VM* vm){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user