make_function asserts arity

上级 dbcf977d
...@@ -52,6 +52,11 @@ class Linker: ...@@ -52,6 +52,11 @@ class Linker:
thunk, inputs, outputs = self.make_thunk(inplace) thunk, inputs, outputs = self.make_thunk(inplace)
def execute(*args): def execute(*args):
def e_arity(takes, got):
return 'Function call takes exactly %i %s (%i given)' \
% (takes, ['argument','arguments'][takes>1], got)
if (len(args) != len(inputs)):
raise TypeError(e_arity(len(inputs), len(args)))
for arg, result in zip(args, inputs): for arg, result in zip(args, inputs):
result.data = arg result.data = arg
thunk() thunk()
...@@ -65,7 +70,6 @@ class Linker: ...@@ -65,7 +70,6 @@ class Linker:
class PerformLinker(Linker): class PerformLinker(Linker):
def make_thunk(self, inplace = False): def make_thunk(self, inplace = False):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论