[pypy-commit] pypy cpyext-avoid-roundtrip: (antocuni, arigo): hopefully fix translation, and add a sanity check to catch these errors earlier in the tests
antocuni
pypy.commits at gmail.com
Tue Oct 10 11:52:21 EDT 2017
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: cpyext-avoid-roundtrip
Changeset: r92707:648fa5150fa6
Date: 2017-10-10 17:51 +0200
http://bitbucket.org/pypy/pypy/changeset/648fa5150fa6/
Log: (antocuni, arigo): hopefully fix translation, and add a sanity check
to catch these errors earlier in the tests
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -433,9 +433,15 @@
arg = input_arg
newargs += (arg, )
try:
- return self.callable(space, *newargs)
+ result = self.callable(space, *newargs)
finally:
keepalive_until_here(*keepalives)
+ #
+ # this is just a sanity check to ensure that we don't forget to
+ # specify result_is_ll=True
+ if self.restype == PyObject:
+ assert self.result_is_ll == is_pyobj(result)
+ return result
return unwrapper
diff --git a/pypy/module/cpyext/sequence.py b/pypy/module/cpyext/sequence.py
--- a/pypy/module/cpyext/sequence.py
+++ b/pypy/module/cpyext/sequence.py
@@ -128,7 +128,7 @@
space.delslice(w_obj, space.newint(start), space.newint(end))
return 0
- at cpython_api([rffi.VOIDP, Py_ssize_t], PyObject)
+ at cpython_api([rffi.VOIDP, Py_ssize_t], PyObject, result_is_ll=True)
def PySequence_ITEM(space, w_obj, i):
"""Return the ith element of o or NULL on failure. Macro form of
PySequence_GetItem() but without checking that
@@ -153,7 +153,7 @@
return py_res
return make_ref(space, space.getitem(w_obj, space.newint(i)))
- at cpython_api([PyObject, Py_ssize_t], PyObject)
+ at cpython_api([PyObject, Py_ssize_t], PyObject, result_is_ll=True)
def PySequence_GetItem(space, w_obj, i):
"""Return the ith element of o, or NULL on failure. This is the equivalent of
the Python expression o[i]."""
More information about the pypy-commit
mailing list