def descr__new__(space, w_type, __args__): from pypy.objspace.std.objectobject import W_ObjectObject from pypy.objspace.std.typeobject import _precheck_for_new # don't allow arguments if the default object.__init__() is about # to be called w_type = _precheck_for_new(space, w_type) w_parentinit, _ = w_type.lookup_where('__init__') if w_parentinit is space.w_object: try: __args__.fixedunpack(0) except ValueError: raise oefmt(space.w_TypeError, "default __new__ takes no parameters") if w_type.is_abstract(): _abstract_method_error(space, w_type) w_obj = space.allocate_instance(W_ObjectObject, w_type) return w_obj
def descr__new__(space, w_type, __args__): from pypy.objspace.std.typeobject import _precheck_for_new w_type = _precheck_for_new(space, w_type) 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): # 2.7: warn about excess arguments when both methods are # overridden space.warn(space.newtext("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(): _abstract_method_error(space, w_type) return space.allocate_instance(W_ObjectObject, w_type)
def descr__new__(space, w_type, __args__): from pypy.objspace.std.typeobject import _precheck_for_new w_type = _precheck_for_new(space, w_type) 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): # 2.7: warn about excess arguments when both methods are # overridden 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(): _abstract_method_error(space, w_type) return space.allocate_instance(W_ObjectObject, w_type)