Author: Ronan Lamy <[email protected]>
Branch: less-stringly-ops
Changeset: r68225:cda622311685
Date: 2013-11-18 03:49 +0000
http://bitbucket.org/pypy/pypy/changeset/cda622311685/
Log: kill all (broken by design) support for **-unpacking
diff --git a/rpython/annotator/argument.py b/rpython/annotator/argument.py
--- a/rpython/annotator/argument.py
+++ b/rpython/annotator/argument.py
@@ -4,11 +4,8 @@
from rpython.annotator.model import SomeTuple
class ArgumentsForTranslation(object):
- w_starstararg = None
- def __init__(self, args_w, keywords=None,
- w_stararg=None, w_starstararg=None):
+ def __init__(self, args_w, keywords=None, w_stararg=None):
self.w_stararg = w_stararg
- assert w_starstararg is None
assert isinstance(args_w, list)
self.arguments_w = args_w
self.keywords = keywords or {}
@@ -50,12 +47,11 @@
def prepend(self, w_firstarg): # used often
"Return a new Arguments with a new argument inserted first."
return ArgumentsForTranslation([w_firstarg] + self.arguments_w,
- self.keywords, self.w_stararg,
- self.w_starstararg)
+ self.keywords, self.w_stararg)
def copy(self):
return ArgumentsForTranslation(self.arguments_w, self.keywords,
- self.w_stararg, self.w_starstararg)
+ self.w_stararg)
def _match_signature(self, scope_w, signature, defaults_w=None):
"""Parse args and kwargs according to the signature of a code object,
@@ -173,7 +169,7 @@
return ArgumentsForTranslation(args_w, dict(zip(self.keywords,
keywords_w)))
@classmethod
- def fromshape(cls, (shape_cnt, shape_keys, shape_star, shape_stst),
data_w):
+ def fromshape(cls, (shape_cnt, shape_keys, shape_star), data_w):
args_w = data_w[:shape_cnt]
p = end_keys = shape_cnt + len(shape_keys)
if shape_star:
@@ -181,30 +177,22 @@
p += 1
else:
w_star = None
- if shape_stst:
- w_starstar = data_w[p]
- p += 1
- else:
- w_starstar = None
return cls(args_w, dict(zip(shape_keys, data_w[shape_cnt:end_keys])),
- w_star, w_starstar)
+ w_star)
def flatten(self):
""" Argument <-> list of w_objects together with "shape" information
"""
- shape_cnt, shape_keys, shape_star, shape_stst = self._rawshape()
+ shape_cnt, shape_keys, shape_star = self._rawshape()
data_w = self.arguments_w + [self.keywords[key] for key in shape_keys]
if shape_star:
data_w.append(self.w_stararg)
- if shape_stst:
- data_w.append(self.w_starstararg)
- return (shape_cnt, shape_keys, shape_star, shape_stst), data_w
+ return (shape_cnt, shape_keys, shape_star), data_w
def _rawshape(self, nextra=0):
shape_cnt = len(self.arguments_w) + nextra # Number of positional args
shape_keys = tuple(sorted(self.keywords))
shape_star = self.w_stararg is not None # Flag: presence of *arg
- shape_stst = self.w_starstararg is not None # Flag: presence of **kwds
- return shape_cnt, shape_keys, shape_star, shape_stst
+ return shape_cnt, shape_keys, shape_star
def rawshape(args, nextra=0):
diff --git a/rpython/annotator/builtin.py b/rpython/annotator/builtin.py
--- a/rpython/annotator/builtin.py
+++ b/rpython/annotator/builtin.py
@@ -307,7 +307,7 @@
r_func, nimplicitarg = s_repr.const.get_r_implfunc()
nbargs = len(args_s) + nimplicitarg
- s_sigs = r_func.get_s_signatures((nbargs, (), False, False))
+ s_sigs = r_func.get_s_signatures((nbargs, (), False))
if len(s_sigs) != 1:
raise TyperError("cannot hlinvoke callable %r with not uniform"
"annotations: %r" % (s_repr.const,
diff --git a/rpython/annotator/test/test_annrpython.py
b/rpython/annotator/test/test_annrpython.py
--- a/rpython/annotator/test/test_annrpython.py
+++ b/rpython/annotator/test/test_annrpython.py
@@ -1065,8 +1065,9 @@
gf2 = graphof(a, f2)
gf3 = graphof(a, f3)
- assert fam1.calltables == {(2, (), False, False): [{fdesc1: gf1}], (1,
(), False, False): [{fdesc1: gf1}]}
- assert fam2.calltables == {(1, (), False, False): [{fdesc2: gf2,
fdesc3: gf3}]}
+ assert fam1.calltables == {(2, (), False): [{fdesc1: gf1}],
+ (1, (), False): [{fdesc1: gf1}]}
+ assert fam2.calltables == {(1, (), False): [{fdesc2: gf2, fdesc3:
gf3}]}
def test_pbc_call_ins(self):
class A(object):
@@ -1117,14 +1118,14 @@
gfA_m = graphof(a, A.m.im_func)
gfC_m = graphof(a, C.m.im_func)
- assert famB_n.calltables == {(1, (), False, False):
[{mdescB_n.funcdesc: gfB_n}] }
- assert famA_m.calltables == {(1, (), False, False):
[{mdescA_m.funcdesc: gfA_m, mdescC_m.funcdesc: gfC_m }] }
+ assert famB_n.calltables == {(1, (), False): [{mdescB_n.funcdesc:
gfB_n}] }
+ assert famA_m.calltables == {(1, (), False): [{mdescA_m.funcdesc:
gfA_m, mdescC_m.funcdesc: gfC_m }] }
mdescCinit = getmdesc(C().__init__)
famCinit = mdescCinit.getcallfamily()
gfCinit = graphof(a, C.__init__.im_func)
- assert famCinit.calltables == {(1, (), False, False):
[{mdescCinit.funcdesc: gfCinit}] }
+ assert famCinit.calltables == {(1, (), False): [{mdescCinit.funcdesc:
gfCinit}] }
def test_isinstance_usigned(self):
def f(x):
@@ -2053,7 +2054,7 @@
someint = annmodel.SomeInteger()
- assert (fdesc.get_s_signatures((2,(),False,False))
+ assert (fdesc.get_s_signatures((2, (), False))
== [([someint,someint],someint)])
def test_emulated_pbc_call_callback(self):
@@ -4080,7 +4081,7 @@
with py.test.raises(annmodel.UnionError) as exc:
a.build_types(f, [int])
- assert ("RPython cannot unify instances with no common base class"
+ assert ("RPython cannot unify instances with no common base class"
in exc.value.msg)
def test_unionerror_iters(self):
@@ -4096,7 +4097,7 @@
with py.test.raises(annmodel.UnionError) as exc:
a.build_types(f, [int])
- assert ("RPython cannot unify incompatible iterator variants" in
+ assert ("RPython cannot unify incompatible iterator variants" in
exc.value.msg)
def test_variable_getattr(self):
diff --git a/rpython/annotator/test/test_argument.py
b/rpython/annotator/test/test_argument.py
--- a/rpython/annotator/test/test_argument.py
+++ b/rpython/annotator/test/test_argument.py
@@ -65,51 +65,51 @@
def test_rawshape(self):
args = MockArgs([1, 2, 3])
- assert rawshape(args) == (3, (), False, False)
+ assert rawshape(args) == (3, (), False)
args = MockArgs([1])
- assert rawshape(args, 2) == (3, (), False, False)
+ assert rawshape(args, 2) == (3, (), False)
args = MockArgs([1, 2, 3, 4, 5])
- assert rawshape(args) == (5, (), False, False)
+ assert rawshape(args) == (5, (), False)
args = MockArgs([1], {'c': 3, 'b': 2})
- assert rawshape(args) == (1, ('b', 'c'), False, False)
+ assert rawshape(args) == (1, ('b', 'c'), False)
args = MockArgs([1], {'c': 5})
- assert rawshape(args) == (1, ('c', ), False, False)
+ assert rawshape(args) == (1, ('c', ), False)
args = MockArgs([1], {'c': 5, 'd': 7})
- assert rawshape(args) == (1, ('c', 'd'), False, False)
+ assert rawshape(args) == (1, ('c', 'd'), False)
args = MockArgs([1, 2, 3, 4, 5], {'e': 5, 'd': 7})
- assert rawshape(args) == (5, ('d', 'e'), False, False)
+ assert rawshape(args) == (5, ('d', 'e'), False)
def test_flatten(self):
args = MockArgs([1, 2, 3])
- assert args.flatten() == ((3, (), False, False), [1, 2, 3])
+ assert args.flatten() == ((3, (), False), [1, 2, 3])
args = MockArgs([1])
- assert args.flatten() == ((1, (), False, False), [1])
+ assert args.flatten() == ((1, (), False), [1])
args = MockArgs([1, 2, 3, 4, 5])
- assert args.flatten() == ((5, (), False, False), [1, 2, 3, 4, 5])
+ assert args.flatten() == ((5, (), False), [1, 2, 3, 4, 5])
args = MockArgs([1], {'c': 3, 'b': 2})
- assert args.flatten() == ((1, ('b', 'c'), False, False), [1, 2, 3])
+ assert args.flatten() == ((1, ('b', 'c'), False), [1, 2, 3])
args = MockArgs([1], {'c': 5})
- assert args.flatten() == ((1, ('c', ), False, False), [1, 5])
+ assert args.flatten() == ((1, ('c', ), False), [1, 5])
args = MockArgs([1], {'c': 5, 'd': 7})
- assert args.flatten() == ((1, ('c', 'd'), False, False), [1, 5, 7])
+ assert args.flatten() == ((1, ('c', 'd'), False), [1, 5, 7])
args = MockArgs([1, 2, 3, 4, 5], {'e': 5, 'd': 7})
- assert args.flatten() == ((5, ('d', 'e'), False, False), [1, 2, 3, 4,
5, 7, 5])
+ assert args.flatten() == ((5, ('d', 'e'), False), [1, 2, 3, 4, 5, 7,
5])
def test_stararg_flowspace_variable(self):
var = object()
- shape = ((2, ('g', ), True, False), [1, 2, 9, var])
+ shape = ((2, ('g', ), True), [1, 2, 9, var])
args = MockArgs([1, 2], {'g': 9}, w_stararg=var)
assert args.flatten() == shape
@@ -117,30 +117,30 @@
assert args.flatten() == shape
def test_fromshape(self):
- shape = ((3, (), False, False), [1, 2, 3])
+ shape = ((3, (), False), [1, 2, 3])
args = MockArgs.fromshape(*shape)
assert args.flatten() == shape
- shape = ((1, (), False, False), [1])
+ shape = ((1, (), False), [1])
args = MockArgs.fromshape(*shape)
assert args.flatten() == shape
- shape = ((5, (), False, False), [1, 2, 3, 4, 5])
+ shape = ((5, (), False), [1, 2, 3, 4, 5])
args = MockArgs.fromshape(*shape)
assert args.flatten() == shape
- shape = ((1, ('b', 'c'), False, False), [1, 2, 3])
+ shape = ((1, ('b', 'c'), False), [1, 2, 3])
args = MockArgs.fromshape(*shape)
assert args.flatten() == shape
- shape = ((1, ('c', ), False, False), [1, 5])
+ shape = ((1, ('c', ), False), [1, 5])
args = MockArgs.fromshape(*shape)
assert args.flatten() == shape
- shape = ((1, ('c', 'd'), False, False), [1, 5, 7])
+ shape = ((1, ('c', 'd'), False), [1, 5, 7])
args = MockArgs.fromshape(*shape)
assert args.flatten() == shape
- shape = ((5, ('d', 'e'), False, False), [1, 2, 3, 4, 5, 7, 5])
+ shape = ((5, ('d', 'e'), False), [1, 2, 3, 4, 5, 7, 5])
args = MockArgs.fromshape(*shape)
assert args.flatten() == shape
diff --git a/rpython/flowspace/argument.py b/rpython/flowspace/argument.py
--- a/rpython/flowspace/argument.py
+++ b/rpython/flowspace/argument.py
@@ -77,10 +77,8 @@
"""Represents the arguments passed into a function call, i.e. the
`a, b, *c, **d` part in `return func(a, b, *c, **d)`.
"""
- def __init__(self, args_w, keywords=None, w_stararg=None,
- w_starstararg=None):
+ def __init__(self, args_w, keywords=None, w_stararg=None):
self.w_stararg = w_stararg
- assert w_starstararg is None, "No **-unpacking in RPython"
assert isinstance(args_w, list)
self.arguments_w = args_w
self.keywords = keywords or {}
@@ -90,11 +88,10 @@
shape_cnt = len(self.arguments_w) # Number of positional args
shape_keys = tuple(sorted(self.keywords))
shape_star = self.w_stararg is not None # Flag: presence of *arg
- shape_stst = False # Flag: presence of **kwds
data_w = self.arguments_w + [self.keywords[key] for key in shape_keys]
if shape_star:
data_w.append(self.w_stararg)
- return (shape_cnt, shape_keys, shape_star, shape_stst), data_w
+ return (shape_cnt, shape_keys, shape_star), data_w
def as_list(self):
assert not self.keywords
diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -926,7 +926,7 @@
key = w_key.value
keywords[key] = w_value
arguments = self.popvalues(n_arguments)
- args = CallSpec(arguments, keywords, w_star, w_starstar)
+ args = CallSpec(arguments, keywords, w_star)
w_function = self.popvalue()
w_result = self.space.call(w_function, args)
self.pushvalue(w_result)
diff --git a/rpython/flowspace/test/test_objspace.py
b/rpython/flowspace/test/test_objspace.py
--- a/rpython/flowspace/test/test_objspace.py
+++ b/rpython/flowspace/test/test_objspace.py
@@ -748,8 +748,7 @@
for block in graph.iterblocks():
for op in block.operations:
assert op.opname == "call_args"
- assert op.args == map(Constant,
- [g, (0, ('x',), False, False), 2])
+ assert op.args == map(Constant, [g, (0, ('x',), False), 2])
def test_catch_importerror_1(self):
def f():
diff --git a/rpython/rtyper/normalizecalls.py b/rpython/rtyper/normalizecalls.py
--- a/rpython/rtyper/normalizecalls.py
+++ b/rpython/rtyper/normalizecalls.py
@@ -92,9 +92,8 @@
else:
return False # nothing to do, all signatures already match
- shape_cnt, shape_keys, shape_star, shape_stst = shape
+ shape_cnt, shape_keys, shape_star = shape
assert not shape_star, "XXX not implemented"
- assert not shape_stst, "XXX not implemented"
# for the first 'shape_cnt' arguments we need to generalize to
# a common type
diff --git a/rpython/rtyper/rbuiltin.py b/rpython/rtyper/rbuiltin.py
--- a/rpython/rtyper/rbuiltin.py
+++ b/rpython/rtyper/rbuiltin.py
@@ -49,8 +49,6 @@
arguments = ArgumentsForTranslation.fromshape(
hop.args_s[1].const, # shape
range(hop.nb_args-2))
- if arguments.w_starstararg is not None:
- raise TyperError("**kwds call not implemented")
if arguments.w_stararg is not None:
# expand the *arg in-place -- it must be a tuple
from rpython.rtyper.rtuple import TupleRepr
@@ -303,7 +301,7 @@
s_callable = r_callable.get_s_callable()
nbargs = len(hop.args_s) - 1 + nimplicitarg
- s_sigs = r_func.get_s_signatures((nbargs, (), False, False))
+ s_sigs = r_func.get_s_signatures((nbargs, (), False))
if len(s_sigs) != 1:
raise TyperError("cannot hlinvoke callable %r with not uniform"
"annotations: %r" % (r_callable,
diff --git a/rpython/rtyper/rpbc.py b/rpython/rtyper/rpbc.py
--- a/rpython/rtyper/rpbc.py
+++ b/rpython/rtyper/rpbc.py
@@ -268,8 +268,8 @@
# lowleveltype wouldn't be Void otherwise
funcdesc, = self.s_pbc.descriptions
tables = [] # find the simple call in the calltable
- for key, table in self.callfamily.calltables.items():
- if not key[1] and not key[2] and not key[3]:
+ for shape, table in self.callfamily.calltables.items():
+ if not shape[1] and not shape[2]:
tables.append(table)
if len(tables) != 1:
raise TyperError("cannot pass a function with various call shapes")
diff --git a/rpython/rtyper/test/test_normalizecalls.py
b/rpython/rtyper/test/test_normalizecalls.py
--- a/rpython/rtyper/test/test_normalizecalls.py
+++ b/rpython/rtyper/test/test_normalizecalls.py
@@ -185,7 +185,7 @@
.+Sub1.fn
.+Sub2.fn
are called with inconsistent numbers of arguments
-sometimes with 2 arguments, sometimes with 1
+sometimes with \d arguments, sometimes with \d
the callers of these functions are:
.+otherfunc
.+dummyfn"""
@@ -224,7 +224,7 @@
from rpython.rtyper import annlowlevel
# annotate, normalize and rtype fn after the fact
- annhelper = annlowlevel.MixLevelHelperAnnotator(typer)
+ annhelper = annlowlevel.MixLevelHelperAnnotator(typer)
graph = annhelper.getgraph(fn, [a.typeannotation(argtype) for argtype
in argtypes],
s_result)
annhelper.finish()
@@ -239,7 +239,7 @@
assert res == 100
res = llinterp.eval_graph(graphof(t, prefn), [2])
assert res == 201
-
+
return t
def test_mix_after_recursion(self):
@@ -248,7 +248,7 @@
return 2*prefn(n-1)
else:
return 1
-
+
t = TranslationContext()
a = t.buildannotator()
a.build_types(prefn, [int])
@@ -260,10 +260,10 @@
return 1
from rpython.rtyper import annlowlevel
- annhelper = annlowlevel.MixLevelHelperAnnotator(typer)
+ annhelper = annlowlevel.MixLevelHelperAnnotator(typer)
graph = annhelper.getgraph(f, [], annmodel.SomeInteger())
annhelper.finish()
-
+
def test_add_more_subclasses(self):
from rpython.rtyper import rclass
from rpython.rtyper.lltypesystem.rclass import ll_issubclass
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit