本文整理汇总了Python中pypy.interpreter.argument.Arguments.unpack方法的典型用法代码示例。如果您正苦于以下问题:Python Arguments.unpack方法的具体用法?Python Arguments.unpack怎么用?Python Arguments.unpack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypy.interpreter.argument.Arguments
的用法示例。
在下文中一共展示了Arguments.unpack方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_unmatch_signature
# 需要导入模块: from pypy.interpreter.argument import Arguments [as 别名]
# 或者: from pypy.interpreter.argument.Arguments import unpack [as 别名]
def test_unmatch_signature(self):
space = DummySpace()
args = Arguments(space, [1, 2, 3])
sig = (["a", "b", "c"], None, None)
data = args.match_signature(sig, [])
new_args = args.unmatch_signature(sig, data)
assert args.unpack() == new_args.unpack()
args = Arguments(space, [1])
sig = (["a", "b", "c"], None, None)
data = args.match_signature(sig, [2, 3])
new_args = args.unmatch_signature(sig, data)
assert args.unpack() == new_args.unpack()
args = Arguments(space, [1, 2, 3, 4, 5])
sig = (["a", "b", "c"], "r", None)
data = args.match_signature(sig, [])
new_args = args.unmatch_signature(sig, data)
assert args.unpack() == new_args.unpack()
args = Arguments(space, [1], {"c": 3, "b": 2})
sig = (["a", "b", "c"], None, None)
data = args.match_signature(sig, [])
new_args = args.unmatch_signature(sig, data)
assert args.unpack() == new_args.unpack()
args = Arguments(space, [1], {"c": 5})
sig = (["a", "b", "c"], None, None)
data = args.match_signature(sig, [2, 3])
new_args = args.unmatch_signature(sig, data)
assert args.unpack() == new_args.unpack()
args = Arguments(space, [1], {"c": 5, "d": 7})
sig = (["a", "b", "c"], None, "kw")
data = args.match_signature(sig, [2, 3])
new_args = args.unmatch_signature(sig, data)
assert args.unpack() == new_args.unpack()
args = Arguments(space, [1, 2, 3, 4, 5], {"e": 5, "d": 7})
sig = (["a", "b", "c"], "r", "kw")
data = args.match_signature(sig, [2, 3])
new_args = args.unmatch_signature(sig, data)
assert args.unpack() == new_args.unpack()
args = Arguments(space, [], {}, w_stararg=[1], w_starstararg={"c": 5, "d": 7})
sig = (["a", "b", "c"], None, "kw")
data = args.match_signature(sig, [2, 3])
new_args = args.unmatch_signature(sig, data)
assert args.unpack() == new_args.unpack()
args = Arguments(space, [1, 2], {"g": 9}, w_stararg=[3, 4, 5], w_starstararg={"e": 5, "d": 7})
sig = (["a", "b", "c"], "r", "kw")
data = args.match_signature(sig, [2, 3])
new_args = args.unmatch_signature(sig, data)
assert args.unpack() == new_args.unpack()
示例2: appcaller
# 需要导入模块: from pypy.interpreter.argument import Arguments [as 别名]
# 或者: from pypy.interpreter.argument.Arguments import unpack [as 别名]
def appcaller(space, *args_w):
if not isinstance(space, ObjSpace):
raise TypeError("first argument must be a space instance.")
# redirect if the space handles this specially
# XXX can this be factored a bit less flow space dependently?
if hasattr(space, 'specialcases'):
sc = space.specialcases
if ApplevelClass in sc:
ret_w = sc[ApplevelClass](space, self, name, args_w)
if ret_w is not None: # it was RPython
return ret_w
# the last argument can be an Arguments
if not args_w:
args = Arguments(space, [])
else:
args = args_w[-1]
assert args is not None
if not isinstance(args, AbstractArguments):
args = Arguments(space, list(args_w))
else:
# ...which is merged with the previous arguments, if any
if len(args_w) > 1:
more_args_w, more_kwds_w = args.unpack()
args = Arguments(space,
list(args_w[:-1]) + more_args_w,
more_kwds_w)
w_func = self.wget(space, name)
return space.call_args(w_func, args)