[pypy-commit] pypy cpyext-gc-support-2: Return a borrowed result from PyList_GetItem by simply switching to the object strategy
arigo
pypy.commits at gmail.com
Sun Feb 14 05:27:47 EST 2016
Author: Armin Rigo <arigo at tunes.org>
Branch: cpyext-gc-support-2
Changeset: r82232:e42c71fc80cc
Date: 2016-02-14 11:27 +0100
http://bitbucket.org/pypy/pypy/changeset/e42c71fc80cc/
Log: Return a borrowed result from PyList_GetItem by simply switching to
the object strategy
diff --git a/pypy/module/cpyext/listobject.py b/pypy/module/cpyext/listobject.py
--- a/pypy/module/cpyext/listobject.py
+++ b/pypy/module/cpyext/listobject.py
@@ -38,7 +38,7 @@
w_list.setitem(index, w_item)
return 0
- at cpython_api([PyObject, Py_ssize_t], PyObject)
+ at cpython_api([PyObject, Py_ssize_t], PyObject, result_borrowed=True)
def PyList_GetItem(space, w_list, index):
"""Return the object at position pos in the list pointed to by p. The
position must be positive, indexing from the end of the list is not
@@ -49,8 +49,9 @@
if index < 0 or index >= w_list.length():
raise OperationError(space.w_IndexError, space.wrap(
"list index out of range"))
- w_item = w_list.getitem(index)
- return borrow_from(w_list, w_item)
+ w_list.switch_to_object_strategy() # make sure we can return a borrowed obj
+ # XXX ^^^ how does this interact with CPyListStrategy?
+ return w_list.getitem(index)
@cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)
More information about the pypy-commit
mailing list