[pypy-commit] pypy kill-flowobjspace: Kill dead code and tests in ArgumentsForTranslation

rlamy noreply at buildbot.pypy.org
Wed Jan 30 17:15:17 CET 2013


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: kill-flowobjspace
Changeset: r60736:c3132de8201b
Date: 2013-01-30 05:11 +0000
http://bitbucket.org/pypy/pypy/changeset/c3132de8201b/

Log:	Kill dead code and tests in ArgumentsForTranslation

diff --git a/rpython/annotator/argument.py b/rpython/annotator/argument.py
--- a/rpython/annotator/argument.py
+++ b/rpython/annotator/argument.py
@@ -58,8 +58,7 @@
         "unpack the *arg and **kwd into arguments_w and keywords_w"
         if w_stararg is not None:
             self._combine_starargs_wrapped(w_stararg)
-        if w_starstararg is not None:
-            self._combine_starstarargs_wrapped(w_starstararg)
+        assert w_starstararg is None
 
     def _combine_starargs_wrapped(self, w_stararg):
         # unpack the * arguments
@@ -67,42 +66,6 @@
         args_w = space.unpackiterable(w_stararg)
         self.arguments_w = self.arguments_w + args_w
 
-    def _combine_starstarargs_wrapped(self, w_starstararg):
-        # unpack the ** arguments
-        space = self.space
-        keywords, values_w = space.view_as_kwargs(w_starstararg)
-        if keywords is not None: # this path also taken for empty dicts
-            if self.keywords is None:
-                self.keywords = keywords
-                self.keywords_w = values_w
-            else:
-                if set(keywords) & set(self.keywords):
-                    raise TypeError("got multiple values for keyword arguments '%s'", set(keywords) & set(self.keywords))
-                self.keywords = self.keywords + keywords
-                self.keywords_w = self.keywords_w + values_w
-            return
-        if space.isinstance_w(w_starstararg, space.w_dict):
-            keys_w = space.unpackiterable(w_starstararg)
-        else:
-            w_keys = space.call_method(w_starstararg, "keys")
-            keys_w = space.unpackiterable(w_keys)
-        keywords_w = [None] * len(keys_w)
-        keywords = [None] * len(keys_w)
-        for i, w_key in enumerate(keys_w):
-            key = space.str_w(w_key)
-            if key in self.keywords:
-                raise TypeError("got multiple values for keyword argument '%s'" % key)
-            keywords[i] = key
-            keywords_w[i] = space.getitem(w_starstararg, w_key)
-        self.keyword_names_w = keys_w
-        if self.keywords is None:
-            self.keywords = keywords
-            self.keywords_w = keywords_w
-        else:
-            self.keywords = self.keywords + keywords
-            self.keywords_w = self.keywords_w + keywords_w
-
-
     def fixedunpack(self, argcount):
         """The simplest argument parsing: get the 'argcount' arguments,
         or raise a real ValueError if the length is wrong."""
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
@@ -3,86 +3,16 @@
 from rpython.annotator.argument import ArgumentsForTranslation, rawshape
 from rpython.flowspace.argument import Signature
 
-class dummy_wrapped_dict(dict):
-    def __nonzero__(self):
-        raise NotImplementedError
-
-class kwargsdict(dict):
-    pass
-
 class DummySpace(object):
     def newtuple(self, items):
         return tuple(items)
 
     def is_true(self, obj):
-        if isinstance(obj, dummy_wrapped_dict):
-            return bool(dict(obj))
         return bool(obj)
 
-    def fixedview(self, it):
-        return list(it)
-
-    def listview(self, it):
-        return list(it)
-
     def unpackiterable(self, it):
         return list(it)
 
-    def view_as_kwargs(self, x):
-        if len(x) == 0:
-            return [], []
-        return None, None
-
-    def newdict(self):
-        return {}
-
-    def newlist(self, l=[]):
-        return l
-
-    def setitem(self, obj, key, value):
-        obj[key] = value
-
-    def getitem(self, obj, key):
-        return obj[key]
-
-    def wrap(self, obj):
-        return obj
-
-    def str_w(self, s):
-        return str(s)
-
-    def len(self, x):
-        return len(x)
-
-    def int_w(self, x):
-        return x
-
-    def eq_w(self, x, y):
-        return x == y
-
-    def isinstance(self, obj, cls):
-        return isinstance(obj, cls)
-    isinstance_w = isinstance
-
-    def exception_match(self, w_type1, w_type2):
-        return issubclass(w_type1, w_type2)
-
-    def call_method(self, obj, name, *args):
-        method = getattr(obj, name)
-        return method(*args)
-
-    def type(self, obj):
-        class Type:
-            def getname(self, space, default='?'):
-                return type(obj).__name__
-        return Type()
-
-
-    w_TypeError = TypeError
-    w_AttributeError = AttributeError
-    w_UnicodeEncodeError = UnicodeEncodeError
-    w_dict = dict
-    w_str = str
 
 def make_arguments_for_translation(space, args_w, keywords_w={},
                                    w_stararg=None, w_starstararg=None):
@@ -184,14 +114,6 @@
                                        w_starstararg={'e': 5, 'd': 7})
         assert rawshape(args) == (2, ('g', ), True, True)
 
-    def test_copy_and_shape(self):
-        space = DummySpace()
-        args = ArgumentsForTranslation(space, ['a'], ['x'], [1],
-                                       ['w1'], {'y': 'w2'})
-        args1 = args.copy()
-        args.combine_if_necessary()
-        assert rawshape(args1) == (1, ('x',), True, True)
-
 
     def test_flatten(self):
         space = DummySpace()


More information about the pypy-commit mailing list