Hi,
When I do this in C (inside a function callable from Python taking a single argument).
Code: Select all
mp_call_function_2(obj, mp_const_none, mp_const_none);
where obj was the argument passed into the function.
Then from the REPL:
Code: Select all
>>> def bar():
... print('bar')
...
>>> my_c_function(bar)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: bar() takes 0 positional arguments but 2 were given
>>>
So it's unexpected that you're seeing a VM crash...?
To answer your question though -- it isn't easy to answer the question "how many params does a function take".
For example:
Internally in the VM, the signature is represented differently depending on how it was defined (i.e. C, inline asm, regular bytecode, etc). The way this is implemented, it's the responsibility of the callee to figure out if it has been given the right number of arguments. Look at fun_builtin_var_call and fun_bc_call for more information for two of those cases.