Author: Philip Jenvey <pjen...@underboss.org> Branch: newinitwarn Changeset: r84564:04d46eae6d93 Date: 2016-05-21 16:00 -0700 http://bitbucket.org/pypy/pypy/changeset/04d46eae6d93/
Log: match cpython's behavior more including its 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 @@ -92,10 +92,16 @@ w_type = _precheck_for_new(space, w_type) # don't allow arguments if the default object.__init__() is about - # to be called + # 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_init is space.w_object: + 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) + elif (w_parent_new is not space.w_object or + w_parent_init is space.w_object): raise oefmt(space.w_TypeError, "object() takes no parameters") if w_type.is_abstract(): @@ -108,11 +114,17 @@ def descr__init__(space, w_obj, __args__): - # don't allow arguments unless __new__ is overridden + # 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_new is space.w_object: + 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) + elif (w_parent_init is not space.w_object or + w_parent_new is space.w_object): raise oefmt(space.w_TypeError, "object.__init__() takes no parameters") _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit