[pypy-commit] pypy default: Restore PyList_GET_ITEM. Oops!
devin.jeanpierre
pypy.commits at gmail.com
Tue Apr 26 17:12:29 EDT 2016
Author: Devin Jeanpierre <jeanpierreda at gmail.com>
Branch:
Changeset: r83924:901323c8c698
Date: 2016-04-26 10:07 -0700
http://bitbucket.org/pypy/pypy/changeset/901323c8c698/
Log: Restore PyList_GET_ITEM. Oops!
diff --git a/pypy/module/cpyext/include/listobject.h b/pypy/module/cpyext/include/listobject.h
--- a/pypy/module/cpyext/include/listobject.h
+++ b/pypy/module/cpyext/include/listobject.h
@@ -1,1 +1,1 @@
-#define PyList_SET_ITEM PyList_SetItem
+#define PyList_GET_ITEM PyList_GetItem
diff --git a/pypy/module/cpyext/test/test_listobject.py b/pypy/module/cpyext/test/test_listobject.py
--- a/pypy/module/cpyext/test/test_listobject.py
+++ b/pypy/module/cpyext/test/test_listobject.py
@@ -137,6 +137,23 @@
module.setlistitem(l,0)
assert l == [None, 2, 3]
+ def test_get_item_macro(self):
+ module = self.import_extension('foo', [
+ ("test_get_item", "METH_NOARGS",
+ """
+ PyObject* o = PyList_New(1);
+
+ PyObject* o2 = PyInt_FromLong(0);
+ PyList_SET_ITEM(o, 0, o2);
+ o2 = NULL;
+
+ PyObject* o3 = PyList_GET_ITEM(o, 0);
+ Py_INCREF(o3);
+ Py_CLEAR(o);
+ return o3;
+ """)])
+ assert module.test_get_item() == 0
+
def test_set_item_macro(self):
"""PyList_SET_ITEM leaks a reference to the target."""
module = self.import_extension('foo', [
More information about the pypy-commit
mailing list