Author: Matti Picus <[email protected]>
Branch:
Changeset: r92114:dcea72970920
Date: 2017-08-09 13:26 +0300
http://bitbucket.org/pypy/pypy/changeset/dcea72970920/
Log: test, fix calling unbound object method with no args like
np.int32.__array__()
diff --git a/pypy/module/cpyext/methodobject.py
b/pypy/module/cpyext/methodobject.py
--- a/pypy/module/cpyext/methodobject.py
+++ b/pypy/module/cpyext/methodobject.py
@@ -210,6 +210,10 @@
def cmethod_descr_call(space, w_self, __args__):
self = space.interp_w(W_PyCFunctionObject, w_self)
args_w, kw_w = __args__.unpack()
+ if len(args_w) < 1:
+ raise oefmt(space.w_TypeError,
+ "descriptor '%s' of '%s' object needs an argument",
+ self.name, self.w_objclass.getname(space))
w_instance = args_w[0] # XXX typecheck missing
w_args = space.newtuple(args_w[1:])
w_kw = space.newdict()
diff --git a/pypy/module/cpyext/test/test_arraymodule.py
b/pypy/module/cpyext/test/test_arraymodule.py
--- a/pypy/module/cpyext/test/test_arraymodule.py
+++ b/pypy/module/cpyext/test/test_arraymodule.py
@@ -21,6 +21,9 @@
assert arr.itemsize == 4
assert arr[2] == 3
assert len(arr.buffer_info()) == 2
+ exc = raises(TypeError, module.array.append)
+ errstr = str(exc.value)
+ assert errstr.startswith("descriptor 'append' of")
arr.append(4)
assert arr.tolist() == [1, 2, 3, 4]
assert len(arr) == 4
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit