[pypy-commit] pypy py3k: py3 compatibility (PEP 3123): use Py_TYPE macro
rlamy
pypy.commits at gmail.com
Tue Oct 4 12:58:54 EDT 2016
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3k
Changeset: r87572:6c40c6a5ce9f
Date: 2016-10-04 17:02 +0100
http://bitbucket.org/pypy/pypy/changeset/6c40c6a5ce9f/
Log: py3 compatibility (PEP 3123): use Py_TYPE macro (grafted from
e2e74511a967517c9fde0832b0467d278183ff13)
diff --git a/pypy/module/cpyext/test/foo.c b/pypy/module/cpyext/test/foo.c
--- a/pypy/module/cpyext/test/foo.c
+++ b/pypy/module/cpyext/test/foo.c
@@ -613,7 +613,7 @@
static PyObject *newCustom(PyObject *self, PyObject *args)
{
PyObject *obj = calloc(1, sizeof(PyObject));
- obj->ob_type = &CustomType;
+ Py_TYPE(obj) = &CustomType;
_Py_NewReference(obj);
return obj;
}
@@ -728,7 +728,7 @@
SimplePropertyType.tp_new = PyType_GenericNew;
InitErrType.tp_new = PyType_GenericNew;
- CustomType.ob_type = &MetaType;
+ Py_TYPE(&CustomType) = &MetaType;
if (PyType_Ready(&CustomType) < 0)
INITERROR;
diff --git a/pypy/module/cpyext/test/test_sliceobject.py b/pypy/module/cpyext/test/test_sliceobject.py
--- a/pypy/module/cpyext/test/test_sliceobject.py
+++ b/pypy/module/cpyext/test/test_sliceobject.py
@@ -15,10 +15,10 @@
def get_indices(w_start, w_stop, w_step, length):
w_slice = space.newslice(w_start, w_stop, w_step)
values = lltype.malloc(Py_ssize_tP.TO, 4, flavor='raw')
-
- res = api.PySlice_GetIndicesEx(w_slice, 100, values,
- rffi.ptradd(values, 1),
- rffi.ptradd(values, 2),
+
+ res = api.PySlice_GetIndicesEx(w_slice, 100, values,
+ rffi.ptradd(values, 1),
+ rffi.ptradd(values, 2),
rffi.ptradd(values, 3))
assert res == 0
rv = values[0], values[1], values[2], values[3]
@@ -31,9 +31,9 @@
def get_indices(w_start, w_stop, w_step, length):
w_slice = space.newslice(w_start, w_stop, w_step)
values = lltype.malloc(Py_ssize_tP.TO, 3, flavor='raw')
-
- res = api.PySlice_GetIndices(w_slice, 100, values,
- rffi.ptradd(values, 1),
+
+ res = api.PySlice_GetIndices(w_slice, 100, values,
+ rffi.ptradd(values, 1),
rffi.ptradd(values, 2))
assert res == 0
rv = values[0], values[1], values[2]
@@ -47,7 +47,7 @@
("clone", "METH_O",
"""
PySliceObject *slice = (PySliceObject *)args;
- if (slice->ob_type != &PySlice_Type) {
+ if (Py_TYPE(slice) != &PySlice_Type) {
PyErr_SetNone(PyExc_ValueError);
return NULL;
}
More information about the pypy-commit
mailing list