[pypy-svn] r73994 - pypy/branch/cpython-extension/pypy/module/cpyext/test
afa at codespeak.net
afa at codespeak.net
Thu Apr 22 21:45:21 CEST 2010
Author: afa
Date: Thu Apr 22 21:45:18 2010
New Revision: 73994
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/test/_sre.c
pypy/branch/cpython-extension/pypy/module/cpyext/test/foo.c
pypy/branch/cpython-extension/pypy/module/cpyext/test/test_borrow.py
pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py
pypy/branch/cpython-extension/pypy/module/cpyext/test/test_pystate.py
Log:
Fix the tests I broke by removing Py_TYPE &co
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/_sre.c
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/_sre.c (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/_sre.c Thu Apr 22 21:45:18 2010
@@ -81,6 +81,9 @@
#define PyObject_DEL(op) PyMem_DEL((op))
#endif
+#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
+#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
+
/* -------------------------------------------------------------------- */
#if defined(_MSC_VER)
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/foo.c
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/foo.c (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/foo.c Thu Apr 22 21:45:18 2010
@@ -264,7 +264,7 @@
{
PyObject *m, *d;
- Py_TYPE(&footype) = &PyType_Type;
+ footype.ob_type = &PyType_Type;
/* Workaround for quirk in Visual Studio, see
<http://www.python.it/faq/faq-3.html#3.24> */
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_borrow.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_borrow.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_borrow.py Thu Apr 22 21:45:18 2010
@@ -19,7 +19,7 @@
state.print_refcounts()
py.test.raises(AssertionError, api.Py_DecRef, one_pyo)
-class AppTestStringObject(AppTestCpythonExtensionBase):
+class AppTestBorrow(AppTestCpythonExtensionBase):
def test_tuple_borrowing(self):
module = self.import_extension('foo', [
("test_borrowing", "METH_NOARGS",
@@ -27,13 +27,13 @@
PyObject *t = PyTuple_New(1);
PyObject *f = PyFloat_FromDouble(42.0);
PyObject *g = NULL;
- printf("Refcnt1: %i\\n", Py_REFCNT(f));
+ printf("Refcnt1: %i\\n", f->ob_refcnt);
PyTuple_SetItem(t, 0, f); // steals reference
- printf("Refcnt2: %i\\n", Py_REFCNT(f));
+ printf("Refcnt2: %i\\n", f->ob_refcnt);
f = PyTuple_GetItem(t, 0); // borrows reference
- printf("Refcnt3: %i\\n", Py_REFCNT(f));
+ printf("Refcnt3: %i\\n", f->ob_refcnt);
g = PyTuple_GetItem(t, 0); // borrows reference again
- printf("Refcnt4: %i\\n", Py_REFCNT(f));
+ printf("Refcnt4: %i\\n", f->ob_refcnt);
printf("COMPARE: %i\\n", f == g);
Py_DECREF(t);
Py_RETURN_TRUE;
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py Thu Apr 22 21:45:18 2010
@@ -421,12 +421,12 @@
static PyObject* foo_pi(PyObject* self, PyObject *args)
{
PyObject *true = Py_True;
- int refcnt = Py_REFCNT(true);
+ int refcnt = true->ob_refcnt;
int refcnt_after;
Py_INCREF(true);
Py_INCREF(true);
PyBool_Check(true);
- refcnt_after = Py_REFCNT(true);
+ refcnt_after = true->ob_refcnt;
Py_DECREF(true);
Py_DECREF(true);
fprintf(stderr, "REFCNT %i %i\\n", refcnt, refcnt_after);
@@ -436,14 +436,14 @@
{
PyObject *true = Py_True;
PyObject *tup = NULL;
- int refcnt = Py_REFCNT(true);
+ int refcnt = true->ob_refcnt;
int refcnt_after;
tup = PyTuple_New(1);
Py_INCREF(true);
if (PyTuple_SetItem(tup, 0, true) < 0)
return NULL;
- refcnt_after = Py_REFCNT(true);
+ refcnt_after = true->ob_refcnt;
Py_DECREF(tup);
fprintf(stderr, "REFCNT2 %i %i\\n", refcnt, refcnt_after);
return PyBool_FromLong(refcnt_after == refcnt);
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_pystate.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_pystate.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_pystate.py Thu Apr 22 21:45:18 2010
@@ -1,6 +1,6 @@
from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase
-class AppTestStringObject(AppTestCpythonExtensionBase):
+class AppTestThreads(AppTestCpythonExtensionBase):
def test_allow_threads(self):
module = self.import_extension('foo', [
("test", "METH_NOARGS",
More information about the Pypy-commit
mailing list