Author: Armin Rigo <ar...@tunes.org>
Branch: py3.5
Changeset: r87841:bf926a7a616f
Date: 2016-10-17 15:06 +0200
http://bitbucket.org/pypy/pypy/changeset/bf926a7a616f/

Log:    object.__init__() now complains in more cases

diff --git a/pypy/objspace/std/objectobject.py 
b/pypy/objspace/std/objectobject.py
--- a/pypy/objspace/std/objectobject.py
+++ b/pypy/objspace/std/objectobject.py
@@ -112,7 +112,9 @@
     if _excess_args(__args__):
         w_type = space.type(w_obj)
         w_parent_new, _ = space.lookup_in_type_where(w_type, '__new__')
-        if w_parent_new is space.w_object:
+        w_parent_init, _ = space.lookup_in_type_where(w_type, '__init__')
+        if (w_parent_new is space.w_object or
+            w_parent_init is not space.w_object):
             raise oefmt(space.w_TypeError,
                         "object.__init__() takes no parameters")
 
diff --git a/pypy/objspace/std/test/test_obj.py 
b/pypy/objspace/std/test/test_obj.py
--- a/pypy/objspace/std/test/test_obj.py
+++ b/pypy/objspace/std/test/test_obj.py
@@ -89,13 +89,7 @@
             def __init__(self):
                 super(B, self).__init__(a=3)
 
-        #-- pypy doesn't raise the DeprecationWarning
-        #with warnings.catch_warnings(record=True) as log:
-        #    warnings.simplefilter("always", DeprecationWarning)
-        #    B()
-        #assert len(log) == 1
-        #assert log[0].message.args == ("object.__init__() takes no 
parameters",)
-        #assert type(log[0].message) is DeprecationWarning
+        raises(TypeError, B)
 
     def test_object_str(self):
         # obscure case: __str__() must delegate to __repr__() without adding
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to