[pypy-svn] r75709 - in pypy/branch/fast-forward/pypy/interpreter: . test
benjamin at codespeak.net
benjamin at codespeak.net
Thu Jul 1 01:14:32 CEST 2010
Author: benjamin
Date: Thu Jul 1 01:14:31 2010
New Revision: 75709
Modified:
pypy/branch/fast-forward/pypy/interpreter/function.py
pypy/branch/fast-forward/pypy/interpreter/test/test_function.py
Log:
complain when both self and class are None
Modified: pypy/branch/fast-forward/pypy/interpreter/function.py
==============================================================================
--- pypy/branch/fast-forward/pypy/interpreter/function.py (original)
+++ pypy/branch/fast-forward/pypy/interpreter/function.py Thu Jul 1 01:14:31 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/branch/fast-forward/pypy/interpreter/test/test_function.py
==============================================================================
--- pypy/branch/fast-forward/pypy/interpreter/test/test_function.py (original)
+++ pypy/branch/fast-forward/pypy/interpreter/test/test_function.py Thu Jul 1 01:14:31 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