[pypy-svn] r77515 - in pypy/trunk/pypy/interpreter: . test
afa at codespeak.net
afa at codespeak.net
Fri Oct 1 00:48:30 CEST 2010
Author: afa
Date: Fri Oct 1 00:48:28 2010
New Revision: 77515
Modified:
pypy/trunk/pypy/interpreter/function.py
pypy/trunk/pypy/interpreter/test/test_function.py
Log:
issue560 resolved: new.instancemethod should complain
when both self and class are None.
Merge of r75709 from branch/fast-forwad
Modified: pypy/trunk/pypy/interpreter/function.py
==============================================================================
--- pypy/trunk/pypy/interpreter/function.py (original)
+++ pypy/trunk/pypy/interpreter/function.py Fri Oct 1 00:48:28 2010
@@ -430,8 +430,11 @@
self.w_class = w_class # possibly space.w_None
def descr_method__new__(space, w_subtype, w_function, w_instance, w_class=None):
- if space.is_w( w_instance, space.w_None ):
+ if space.is_w(w_instance, space.w_None):
w_instance = None
+ if w_instance is None and space.is_w(w_class, space.w_None):
+ raise OperationError(space.w_TypeError,
+ space.wrap("unbound methods must have class"))
method = space.allocate_instance(Method, w_subtype)
Method.__init__(method, space, w_function, w_instance, w_class)
return space.wrap(method)
Modified: pypy/trunk/pypy/interpreter/test/test_function.py
==============================================================================
--- pypy/trunk/pypy/interpreter/test/test_function.py (original)
+++ pypy/trunk/pypy/interpreter/test/test_function.py Fri Oct 1 00:48:28 2010
@@ -482,6 +482,11 @@
raises(TypeError, m, MyInst(None))
raises(TypeError, m, MyInst(42))
+ def test_invalid_creation(self):
+ import new
+ def f(): pass
+ raises(TypeError, new.instancemethod, f, None)
+
class TestMethod:
def setup_method(self, method):
More information about the Pypy-commit
mailing list