[pypy-commit] pypy refactor-pycall: cleanup
rlamy
noreply at buildbot.pypy.org
Thu Apr 2 16:48:05 CEST 2015
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: refactor-pycall
Changeset: r76690:ca74b99d487b
Date: 2015-04-02 15:47 +0100
http://bitbucket.org/pypy/pypy/changeset/ca74b99d487b/
Log: cleanup
diff --git a/rpython/rtyper/normalizecalls.py b/rpython/rtyper/normalizecalls.py
--- a/rpython/rtyper/normalizecalls.py
+++ b/rpython/rtyper/normalizecalls.py
@@ -86,12 +86,7 @@
return False # nothing to do, all signatures already match
shape_cnt, shape_keys, shape_star = shape
- if shape_star:
- raise TyperError(
- "not implemented: a call is done with a '*' argument, and the"
- " multiple functions or methods that it can go to don't have"
- " all the same signature (different argument names or defaults)."
- " The call can go to:\n%s" % '\n'.join(map(repr, graphs)))
+ assert not shape_star, "should have been removed at this stage"
# 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
@@ -47,31 +47,14 @@
# to it.
return (self.__class__, self.methodname, id(self.s_self))
-def call_args_expand(hop, takes_kwds = True):
+def call_args_expand(hop):
hop = hop.copy()
from rpython.annotator.argument import ArgumentsForTranslation
arguments = ArgumentsForTranslation.fromshape(
hop.args_s[1].const, # shape
range(hop.nb_args-2))
- if arguments.w_stararg is not None:
- # expand the *arg in-place -- it must be a tuple
- from rpython.rtyper.rtuple import TupleRepr
- if arguments.w_stararg != hop.nb_args - 3:
- raise TyperError("call pattern too complex")
- v_tuple = hop.args_v.pop()
- s_tuple = hop.args_s.pop()
- r_tuple = hop.args_r.pop()
- if not isinstance(r_tuple, TupleRepr):
- raise TyperError("*arg must be a tuple")
- for i in range(len(r_tuple.items_r)):
- v_item = r_tuple.getitem_internal(hop.llops, v_tuple, i)
- hop.args_v.append(v_item)
- hop.args_s.append(s_tuple.items[i])
- hop.args_r.append(r_tuple.items_r[i])
-
+ assert arguments.w_stararg is None
keywords = arguments.keywords
- if not takes_kwds and keywords:
- raise TyperError("kwds args not supported")
# prefix keyword arguments with 'i_'
kwds_i = {}
for key in keywords:
diff --git a/rpython/rtyper/rptr.py b/rpython/rtyper/rptr.py
--- a/rpython/rtyper/rptr.py
+++ b/rpython/rtyper/rptr.py
@@ -1,4 +1,3 @@
-from rpython.annotator import model as annmodel
from rpython.rtyper.llannotation import (
SomePtr, SomeInteriorPtr, SomeLLADTMeth, lltype_to_annotation)
from rpython.flowspace import model as flowmodel
@@ -107,11 +106,7 @@
resulttype = self.lowleveltype.TO.RESULT)
def rtype_call_args(self, hop):
- from rpython.rtyper.rbuiltin import call_args_expand
- hop, _ = call_args_expand(hop, takes_kwds=False)
- hop.swap_fst_snd_args()
- hop.r_s_popfirstarg()
- return self.rtype_simple_call(hop)
+ raise TyperError("kwds args not supported")
class __extend__(pairtype(PtrRepr, PtrRepr)):
def convert_from_to((r_ptr1, r_ptr2), v, llop):
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
@@ -237,25 +237,6 @@
import re
assert re.match(msg, excinfo.value.args[0])
- def test_methods_with_named_arg_call(self):
- class Base:
- def fn(self, y):
- raise NotImplementedError
- class Sub1(Base):
- def fn(self, y):
- return 1 + y
- class Sub2(Base):
- def fn(self, x): # different name!
- return x - 2
- def dummyfn(n):
- if n == 1:
- s = Sub1()
- else:
- s = Sub2()
- return s.fn(*(n,))
-
- py.test.raises(TyperError, self.rtype, dummyfn, [int], int)
-
class PBase:
def fn(self):
More information about the pypy-commit
mailing list