[pypy-commit] pypy newinitwarn: backoutish 57573ddc5c33: match cpython's warnings
pjenvey
pypy.commits at gmail.com
Tue Oct 25 00:32:47 EDT 2016
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: newinitwarn
Changeset: r87923:ffe0b11d6f58
Date: 2016-10-24 21:28 -0700
http://bitbucket.org/pypy/pypy/changeset/ffe0b11d6f58/
Log: backoutish 57573ddc5c33: match cpython's warnings
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
@@ -91,19 +91,17 @@
from pypy.objspace.std.typeobject import _precheck_for_new
w_type = _precheck_for_new(space, w_type)
- # don't allow arguments if the default object.__init__() is about
- # to be called XXX: more rules
if _excess_args(__args__):
w_parent_new, _ = space.lookup_in_type_where(w_type, '__new__')
w_parent_init, _ = space.lookup_in_type_where(w_type, '__init__')
if (w_parent_new is not space.w_object and
w_parent_init is not space.w_object):
- #space.warn(space.wrap("object() takes no parameters"),
- # space.w_DeprecationWarning, 1)
- raise oefmt(space.w_TypeError,
- "!!object() takes no parameters")
+ space.warn(space.wrap("object() takes no parameters"),
+ space.w_DeprecationWarning, 1)
elif (w_parent_new is not space.w_object or
w_parent_init is space.w_object):
+ # 2.7: warn about excess arguments when both methods are
+ # overridden
raise oefmt(space.w_TypeError,
"object() takes no parameters")
if w_type.is_abstract():
@@ -116,17 +114,16 @@
def descr__init__(space, w_obj, __args__):
- # don't allow arguments unless __new__ is overridden XXX: more rules
if _excess_args(__args__):
w_type = space.type(w_obj)
w_parent_init, _ = space.lookup_in_type_where(w_type, '__init__')
w_parent_new, _ = space.lookup_in_type_where(w_type, '__new__')
if (w_parent_init is not space.w_object and
w_parent_new is not space.w_object):
- #space.warn(space.wrap("object.__init__() takes no parameters"),
- # space.w_DeprecationWarning, 1)
- raise oefmt(space.w_TypeError,
- "!!!!object.__init__() takes no parameters")
+ # 2.7: warn about excess arguments when both methods are
+ # overridden
+ space.warn(space.wrap("object.__init__() takes no parameters"),
+ space.w_DeprecationWarning, 1)
elif (w_parent_init is not space.w_object or
w_parent_new is space.w_object):
raise oefmt(space.w_TypeError,
More information about the pypy-commit
mailing list