Author: Armin Rigo <[email protected]>
Branch: cpyext-avoid-roundtrip
Changeset: r92709:8d6f9c10803c
Date: 2017-10-10 18:25 +0200
http://bitbucket.org/pypy/pypy/changeset/8d6f9c10803c/

Log:    (antocuni, arigo)

        Fix two different tests

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
@@ -137,6 +137,9 @@
 
     This function used an int type for i. This might require
     changes in your code for properly supporting 64-bit systems."""
+    # XXX we should call Py*_GET_ITEM() instead of Py*_GetItem()
+    # from here, but we cannot because we are also called from
+    # PySequence_GetItem()
     if isinstance(w_obj, tupleobject.W_TupleObject):
         from pypy.module.cpyext.tupleobject import PyTuple_GetItem
         py_obj = as_pyobj(space, w_obj)
@@ -145,9 +148,9 @@
         keepalive_until_here(w_obj)
         return py_res
     if isinstance(w_obj, W_ListObject):
-        from pypy.module.cpyext.listobject import PyList_GET_ITEM
+        from pypy.module.cpyext.listobject import PyList_GetItem
         py_obj = as_pyobj(space, w_obj)
-        py_res = PyList_GET_ITEM(space, py_obj, i)
+        py_res = PyList_GetItem(space, py_obj, i)
         incref(space, py_res)
         keepalive_until_here(w_obj)
         return py_res
diff --git a/pypy/module/cpyext/test/test_sequence.py 
b/pypy/module/cpyext/test/test_sequence.py
--- a/pypy/module/cpyext/test/test_sequence.py
+++ b/pypy/module/cpyext/test/test_sequence.py
@@ -5,6 +5,7 @@
 from pypy.module.cpyext.sequence import (
     PySequence_Fast, PySequence_Contains, PySequence_Index,
     PySequence_GetItem, PySequence_SetItem, PySequence_DelItem)
+from pypy.module.cpyext.pyobject import get_w_obj_and_decref
 
 import pytest
 
@@ -134,9 +135,11 @@
     def test_getitem(self, space, api):
         thelist = [8, 7, 6, 5, 4, 3, 2, 1]
         w_l = space.wrap(thelist)
-        result = api.PySequence_GetItem(w_l, 4)
+        py_result = api.PySequence_GetItem(w_l, 4)
+        result = get_w_obj_and_decref(space, py_result)
         assert space.is_true(space.eq(result, space.wrap(4)))
-        result = api.PySequence_ITEM(w_l, 4)
+        py_result = api.PySequence_ITEM(w_l, 4)
+        result = get_w_obj_and_decref(space, py_result)
         assert space.is_true(space.eq(result, space.wrap(4)))
         with raises_w(space, IndexError):
             PySequence_GetItem(space, w_l, 9000)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to