[pypy-svn] pypy default: Simplify the logic and don't give a DeprecationWarning.
arigo
commits-noreply at bitbucket.org
Wed Mar 16 11:18:38 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r42707:e7e53bd568e9
Date: 2011-03-16 06:15 -0400
http://bitbucket.org/pypy/pypy/changeset/e7e53bd568e9/
Log: Simplify the logic and don't give a DeprecationWarning. I don't
really understand why but it gives troubles to some lib-python
tests. Maybe it's related to the fact that descr_init's logic was
exactly like CPython's, but descr_new's logic was not.
diff --git a/pypy/objspace/std/objecttype.py b/pypy/objspace/std/objecttype.py
--- a/pypy/objspace/std/objecttype.py
+++ b/pypy/objspace/std/objecttype.py
@@ -78,19 +78,15 @@
return w_obj
def descr__init__(space, w_obj, __args__):
+ # don't allow arguments unless __new__ is overridden
w_type = space.type(w_obj)
w_parent_new, _ = w_type.lookup_where('__new__')
- w_parent_init, _ = w_type.lookup_where('__init__')
- try:
- __args__.fixedunpack(0)
- except ValueError:
- if w_parent_new is not space.w_object and w_parent_init is not space.w_object:
- space.warn("object.__init__() takes no parameters", space.w_DeprecationWarning)
- elif w_parent_new is space.w_object or w_parent_init is not space.w_object:
+ if w_parent_new is space.w_object:
+ try:
+ __args__.fixedunpack(0)
+ except ValueError:
raise OperationError(space.w_TypeError,
- space.wrap("object.__init__() takes no parameters")
- )
-
+ space.wrap("object.__init__() takes no parameters"))
@gateway.unwrap_spec(proto=int)
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
@@ -87,9 +87,10 @@
def __init__(self):
super(B, self).__init__(a=3)
- 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
+ #-- 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
More information about the Pypy-commit
mailing list