Author: Maciej Fijalkowski <[email protected]>
Branch: 
Changeset: r58377:91acb9facc77
Date: 2012-10-23 11:56 +0200
http://bitbucket.org/pypy/pypy/changeset/91acb9facc77/

Log:    (arigo, fijal) Some simplifications, test and a fix on PyPy

diff --git a/pypy/annotation/builtin.py b/pypy/annotation/builtin.py
--- a/pypy/annotation/builtin.py
+++ b/pypy/annotation/builtin.py
@@ -404,7 +404,10 @@
     BUILTIN_ANALYZERS[unicodedata.decimal] = unicodedata_decimal # xxx
 
 # object - just ignore object.__init__
-BUILTIN_ANALYZERS[object.__init__] = object_init
+if hasattr(object.__init__, 'im_func'):
+    BUILTIN_ANALYZERS[object.__init__.im_func] = object_init
+else:
+    BUILTIN_ANALYZERS[object.__init__] = object_init    
 
 # import
 BUILTIN_ANALYZERS[__import__] = import_func
diff --git a/pypy/annotation/test/test_annrpython.py 
b/pypy/annotation/test/test_annrpython.py
--- a/pypy/annotation/test/test_annrpython.py
+++ b/pypy/annotation/test/test_annrpython.py
@@ -3805,6 +3805,20 @@
         s = a.build_types(f, [annmodel.SomeInteger()])
         assert isinstance(s, annmodel.SomeBool)
 
+    def test_object_init(self):
+        class A(object):
+            pass
+
+        class B(A):
+            def __init__(self):
+                A.__init__(self)
+
+        def f():
+            B()
+
+        a = self.RPythonAnnotator()
+        a.build_types(f, []) # assert did not explode
+
 def g(n):
     return [0,1,2,n]
 
diff --git a/pypy/objspace/flow/argument.py b/pypy/objspace/flow/argument.py
--- a/pypy/objspace/flow/argument.py
+++ b/pypy/objspace/flow/argument.py
@@ -201,8 +201,7 @@
         elif num_args > co_argcount:
             raise ArgErrCount(num_args, num_kwds, signature, defaults_w, 0)
 
-        # if a **kwargs argument is needed, create the dict
-        w_kwds = None
+        # if a **kwargs argument is needed, explode
         if signature.has_kwarg():
             raise TypeError("Keyword arguments as **kwargs is not supported by 
RPython")
 
@@ -235,24 +234,10 @@
                     num_remainingkwds -= 1
 
             if num_remainingkwds:
-                if w_kwds is not None:
-                    # collect extra keyword arguments into the **kwarg
-                    limit = len(keywords)
-                    if self.keyword_names_w is not None:
-                        limit -= len(self.keyword_names_w)
-                    for i in range(len(keywords)):
-                        if i in kwds_mapping:
-                            continue
-                        if i < limit:
-                            w_key = self.space.wrap(keywords[i])
-                        else:
-                            w_key = self.keyword_names_w[i - limit]
-                        self.space.setitem(w_kwds, w_key, keywords_w[i])
-                else:
-                    if co_argcount == 0:
-                        raise ArgErrCount(num_args, num_kwds, signature, 
defaults_w, 0)
-                    raise ArgErrUnknownKwds(self.space, num_remainingkwds, 
keywords,
-                                            kwds_mapping, self.keyword_names_w)
+                if co_argcount == 0:
+                    raise ArgErrCount(num_args, num_kwds, signature, 
defaults_w, 0)
+                raise ArgErrUnknownKwds(self.space, num_remainingkwds, 
keywords,
+                                        kwds_mapping, self.keyword_names_w)
 
         # check for missing arguments and fill them from the kwds,
         # or with defaults, if available
diff --git a/pypy/objspace/flow/test/test_argument.py 
b/pypy/objspace/flow/test/test_argument.py
--- a/pypy/objspace/flow/test/test_argument.py
+++ b/pypy/objspace/flow/test/test_argument.py
@@ -81,9 +81,7 @@
             return [], []
         return None, None
 
-    def newdict(self, kwargs=False):
-        if kwargs:
-            return kwargsdict()
+    def newdict(self):
         return {}
 
     def newlist(self, l=[]):
@@ -199,31 +197,7 @@
 
         args = make_arguments_for_translation(space, [1], {'c': 5, 'd': 7})
         sig = Signature(['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 = make_arguments_for_translation(space, [1,2,3,4,5], {'e': 5, 
'd': 7})
-        sig = Signature(['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 = make_arguments_for_translation(space, [], {},
-                                       w_stararg=[1],
-                                       w_starstararg={'c': 5, 'd': 7})
-        sig = Signature(['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 = make_arguments_for_translation(space, [1,2], {'g': 9},
-                                       w_stararg=[3,4,5],
-                                       w_starstararg={'e': 5, 'd': 7})
-        sig = Signature(['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()
+        py.test.raises(TypeError, args.match_signature, sig, [2, 3])
 
     def test_rawshape(self):
         space = DummySpace()
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to