[pypy-commit] pypy cpyext-avoid-roundtrip: fix this test, now that the empty tuple is cached also on pypy; fix also the type of initial_item_refcount, because int is not large enough to contain REFCNT_FROM_PYPY

antocuni pypy.commits at gmail.com
Fri Oct 13 17:30:33 EDT 2017


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: cpyext-avoid-roundtrip
Changeset: r92748:cfae668eb6e9
Date: 2017-10-13 23:25 +0200
http://bitbucket.org/pypy/pypy/changeset/cfae668eb6e9/

Log:	fix this test, now that the empty tuple is cached also on pypy; fix
	also the type of initial_item_refcount, because int is not large
	enough to contain REFCNT_FROM_PYPY

diff --git a/pypy/module/cpyext/test/test_tupleobject.py b/pypy/module/cpyext/test/test_tupleobject.py
--- a/pypy/module/cpyext/test/test_tupleobject.py
+++ b/pypy/module/cpyext/test/test_tupleobject.py
@@ -90,13 +90,9 @@
              """
                 PyObject *item = PyTuple_New(0);
                 PyObject *t = PyTuple_New(1);
-#ifdef PYPY_VERSION
-                // PyPy starts even empty tuples with a refcount of 1.
-                const int initial_item_refcount = 1;
-#else
-                // CPython can cache ().
-                const int initial_item_refcount = item->ob_refcnt;
-#endif  // PYPY_VERSION
+                // the empty tuple is cached, so we can't assume its refcnt is 1
+                const Py_ssize_t initial_item_refcount = item->ob_refcnt;
+
                 if (t->ob_refcnt != 1 || item->ob_refcnt != initial_item_refcount) {
                     PyErr_SetString(PyExc_SystemError, "bad initial refcnt");
                     return NULL;


More information about the pypy-commit mailing list