Author: Matti Picus <[email protected]>
Branch:
Changeset: r87452:106a495914a5
Date: 2016-09-29 20:27 +0300
http://bitbucket.org/pypy/pypy/changeset/106a495914a5/
Log: make sure exception is raised if call returns error value
diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py
--- a/pypy/module/cpyext/slotdefs.py
+++ b/pypy/module/cpyext/slotdefs.py
@@ -214,7 +214,10 @@
i = space.int_w(space.index(args_w[0]))
j = space.int_w(space.index(args_w[1]))
w_y = args_w[2]
- return space.wrap(generic_cpy_call(space, func_target, w_self, i, j, w_y))
+ res = generic_cpy_call(space, func_target, w_self, i, j, w_y)
+ if rffi.cast(lltype.Signed, res) == -1:
+ space.fromcache(State).check_and_raise_exception(always=True)
+ return res
def wrap_lenfunc(space, w_self, w_args, func):
func_len = rffi.cast(lenfunc, func)
@@ -296,7 +299,10 @@
def wrap_hashfunc(space, w_self, w_args, func):
func_target = rffi.cast(hashfunc, func)
check_num_args(space, w_args, 0)
- return space.wrap(generic_cpy_call(space, func_target, w_self))
+ res = generic_cpy_call(space, func_target, w_self)
+ if res == -1:
+ space.fromcache(State).check_and_raise_exception(always=True)
+ return space.wrap(res)
class CPyBuffer(Buffer):
# Similar to Py_buffer
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
@@ -49,6 +49,7 @@
assert arr.tolist() == [1, 21, 22, 23, 4]
del arr[slice(1, 3)]
assert arr.tolist() == [1, 23, 4]
+ raises(TypeError, 'arr[slice(1, 3)] = "abc"')
def test_buffer(self):
import sys
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit