[pypy-svn] pypy default: Add a failing test about borrowed references.
amauryfa
commits-noreply at bitbucket.org
Fri Mar 11 13:41:28 CET 2011
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch:
Changeset: r42508:a4e4beea777e
Date: 2011-03-11 13:41 +0100
http://bitbucket.org/pypy/pypy/changeset/a4e4beea777e/
Log: Add a failing test about borrowed references. You'd better not
borrow the same object from different containers...
diff --git a/pypy/module/cpyext/test/test_borrow.py b/pypy/module/cpyext/test/test_borrow.py
--- a/pypy/module/cpyext/test/test_borrow.py
+++ b/pypy/module/cpyext/test/test_borrow.py
@@ -38,3 +38,24 @@
])
assert module.test_borrowing() # the test should not leak
+ def test_borrow_destroy(self):
+ skip("FIXME")
+ module = self.import_extension('foo', [
+ ("test_borrow_destroy", "METH_NOARGS",
+ """
+ PyObject *i = PyInt_FromLong(42);
+ PyObject *j;
+ PyObject *t1 = PyTuple_Pack(1, i);
+ PyObject *t2 = PyTuple_Pack(1, i);
+ Py_DECREF(i);
+
+ i = PyTuple_GetItem(t1, 0);
+ PyTuple_GetItem(t2, 0);
+ Py_DECREF(t2);
+
+ j = PyInt_FromLong(PyInt_AsLong(i));
+ Py_DECREF(t1);
+ return j;
+ """),
+ ])
+ assert module.test_borrow_destroy() == 42
More information about the Pypy-commit
mailing list