[pypy-commit] pypy py3k: PyInt_ apis -> PyLong_
pjenvey
noreply at buildbot.pypy.org
Thu Apr 11 22:37:20 CEST 2013
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r63246:8bc3fa4eca19
Date: 2013-04-11 13:35 -0700
http://bitbucket.org/pypy/pypy/changeset/8bc3fa4eca19/
Log: PyInt_ apis -> PyLong_
diff --git a/pypy/module/cpyext/dictobject.py b/pypy/module/cpyext/dictobject.py
--- a/pypy/module/cpyext/dictobject.py
+++ b/pypy/module/cpyext/dictobject.py
@@ -157,8 +157,8 @@
Py_ssize_t pos = 0;
while (PyDict_Next(self->dict, &pos, &key, &value)) {
- int i = PyInt_AS_LONG(value) + 1;
- PyObject *o = PyInt_FromLong(i);
+ int i = PyLong_AS_LONG(value) + 1;
+ PyObject *o = PyLong_FromLong(i);
if (o == NULL)
return -1;
if (PyDict_SetItem(self->dict, key, o) < 0) {
diff --git a/pypy/module/cpyext/test/comparisons.c b/pypy/module/cpyext/test/comparisons.c
--- a/pypy/module/cpyext/test/comparisons.c
+++ b/pypy/module/cpyext/test/comparisons.c
@@ -1,5 +1,9 @@
#include "Python.h"
+#if PY_MAJOR_VERSION >= 3
+ #define PyInt_CheckExact PyLong_CheckExact
+#endif
+
typedef struct CmpObject {
PyObject_HEAD
} CmpObject;
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
@@ -1,6 +1,11 @@
#include "Python.h"
#include "structmember.h"
+#if PY_MAJOR_VERSION >= 3
+ #define PyInt_FromLong PyLong_FromLong
+ #define PyInt_AsLong PyLong_AsLong
+#endif
+
typedef struct {
PyObject_HEAD
int foo; /* the context holder */
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
@@ -42,7 +42,7 @@
module = self.import_extension('foo', [
("test_borrow_destroy", "METH_NOARGS",
"""
- PyObject *i = PyInt_FromLong(42);
+ PyObject *i = PyLong_FromLong(42);
PyObject *j;
PyObject *t1 = PyTuple_Pack(1, i);
PyObject *t2 = PyTuple_Pack(1, i);
@@ -52,7 +52,7 @@
PyTuple_GetItem(t2, 0);
Py_DECREF(t2);
- j = PyInt_FromLong(PyInt_AsLong(i));
+ j = PyLong_FromLong(PyLong_AsLong(i));
Py_DECREF(t1);
return j;
"""),
diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py
--- a/pypy/module/cpyext/test/test_cpyext.py
+++ b/pypy/module/cpyext/test/test_cpyext.py
@@ -738,7 +738,7 @@
mod = self.import_extension('foo', [
('get_hash', 'METH_NOARGS',
'''
- return PyInt_FromLong(_Py_HashPointer(Py_None));
+ return PyLong_FromLong(_Py_HashPointer(Py_None));
'''
),
])
diff --git a/pypy/module/cpyext/test/test_getargs.py b/pypy/module/cpyext/test/test_getargs.py
--- a/pypy/module/cpyext/test/test_getargs.py
+++ b/pypy/module/cpyext/test/test_getargs.py
@@ -18,7 +18,7 @@
if (!PyArg_ParseTuple(args, "i", &l)) {
return NULL;
}
- return PyInt_FromLong(l);
+ return PyLong_FromLong(l);
''')
assert oneargint(1) == 1
raises(TypeError, oneargint, None)
@@ -36,7 +36,7 @@
if (!PyArg_ParseTuple(args, "i:oneargandstuff", &l)) {
return NULL;
}
- return PyInt_FromLong(l);
+ return PyLong_FromLong(l);
''')
assert oneargandform(1) == 1
@@ -94,7 +94,7 @@
if (b)
Py_INCREF(b);
else
- b = PyInt_FromLong(42);
+ b = PyLong_FromLong(42);
/* return an owned reference */
return b;
''')
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
@@ -70,16 +70,16 @@
("newlist", "METH_NOARGS",
"""
PyObject *lst = PyList_New(3);
- PyList_SetItem(lst, 0, PyInt_FromLong(3));
- PyList_SetItem(lst, 2, PyInt_FromLong(1000));
- PyList_SetItem(lst, 1, PyInt_FromLong(-5));
+ PyList_SetItem(lst, 0, PyLong_FromLong(3));
+ PyList_SetItem(lst, 2, PyLong_FromLong(1000));
+ PyList_SetItem(lst, 1, PyLong_FromLong(-5));
return lst;
"""
),
("setlistitem", "METH_VARARGS",
"""
PyObject *l = PyTuple_GetItem(args, 0);
- int index = PyInt_AsLong(PyTuple_GetItem(args, 1));
+ int index = PyLong_AsLong(PyTuple_GetItem(args, 1));
Py_INCREF(Py_None);
if (PyList_SetItem(l, index, Py_None) < 0)
return NULL;
diff --git a/pypy/module/cpyext/test/test_number.py b/pypy/module/cpyext/test/test_number.py
--- a/pypy/module/cpyext/test/test_number.py
+++ b/pypy/module/cpyext/test/test_number.py
@@ -22,11 +22,11 @@
def test_number_int(self, space, api):
w_l = api.PyNumber_Int(space.wraplong(123L))
- assert api.PyInt_CheckExact(w_l)
+ assert api.PyLong_CheckExact(w_l)
w_l = api.PyNumber_Int(space.wrap(2 << 65))
assert api.PyLong_CheckExact(w_l)
w_l = api.PyNumber_Int(space.wrap(42.3))
- assert api.PyInt_CheckExact(w_l)
+ assert api.PyLong_CheckExact(w_l)
def test_number_index(self, space, api):
w_l = api.PyNumber_Index(space.wraplong(123L))
diff --git a/pypy/module/cpyext/test/test_pysignals.py b/pypy/module/cpyext/test/test_pysignals.py
--- a/pypy/module/cpyext/test/test_pysignals.py
+++ b/pypy/module/cpyext/test/test_pysignals.py
@@ -21,7 +21,7 @@
if( handler != SIG_IGN )
result += 2;
- return PyInt_FromLong(result);
+ return PyLong_FromLong(result);
"""),
], prologue = """
#include <signal.h>
diff --git a/pypy/module/cpyext/test/test_structseq.py b/pypy/module/cpyext/test/test_structseq.py
--- a/pypy/module/cpyext/test/test_structseq.py
+++ b/pypy/module/cpyext/test/test_structseq.py
@@ -33,8 +33,8 @@
if (PyErr_Occurred()) return NULL;
seq = PyStructSequence_New(&PyDatatype);
if (!seq) return NULL;
- PyStructSequence_SET_ITEM(seq, 0, PyInt_FromLong(42));
- PyStructSequence_SET_ITEM(seq, 1, PyInt_FromLong(43));
+ PyStructSequence_SET_ITEM(seq, 0, PyLong_FromLong(42));
+ PyStructSequence_SET_ITEM(seq, 1, PyLong_FromLong(43));
PyStructSequence_SET_ITEM(seq, 2, PyUnicode_FromString("hello"));
PyStructSequence_SET_ITEM(seq, 3, PyUnicode_FromString("other"));
Py_DECREF(&PyDatatype);
diff --git a/pypy/module/cpyext/test/test_thread.py b/pypy/module/cpyext/test/test_thread.py
--- a/pypy/module/cpyext/test/test_thread.py
+++ b/pypy/module/cpyext/test/test_thread.py
@@ -9,7 +9,7 @@
("get_thread_ident", "METH_NOARGS",
"""
/* Use the 'PyPy' prefix to ensure we access our functions */
- return PyInt_FromLong(PyPyThread_get_thread_ident());
+ return PyLong_FromLong(PyPyThread_get_thread_ident());
"""),
])
import threading
@@ -72,11 +72,11 @@
module = self.import_extension('foo', [
("create_key", "METH_NOARGS",
"""
- return PyInt_FromLong(PyThread_create_key());
+ return PyLong_FromLong(PyThread_create_key());
"""),
("test_key", "METH_O",
"""
- int key = PyInt_AsLong(args);
+ int key = PyLong_AsLong(args);
if (PyThread_get_key_value(key) != NULL) {
PyErr_SetNone(PyExc_ValueError);
return NULL;
diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py
--- a/pypy/module/cpyext/test/test_typeobject.py
+++ b/pypy/module/cpyext/test/test_typeobject.py
@@ -449,7 +449,7 @@
static int
mp_ass_subscript(PyObject *self, PyObject *key, PyObject *value)
{
- if (PyInt_Check(key)) {
+ if (PyLong_Check(key)) {
PyErr_SetNone(PyExc_ZeroDivisionError);
return -1;
}
diff --git a/pypy/module/cpyext/test/test_unicodeobject.py b/pypy/module/cpyext/test/test_unicodeobject.py
--- a/pypy/module/cpyext/test/test_unicodeobject.py
+++ b/pypy/module/cpyext/test/test_unicodeobject.py
@@ -79,7 +79,7 @@
("test_unicode_format_v", "METH_VARARGS",
'''
return helper("bla %d ble %s\\n",
- PyInt_AsLong(PyTuple_GetItem(args, 0)),
+ PyLong_AsLong(PyTuple_GetItem(args, 0)),
_PyUnicode_AsString(PyTuple_GetItem(args, 1)));
'''
)
@@ -102,7 +102,7 @@
("test_unicode_format", "METH_VARARGS",
'''
return PyUnicode_FromFormat("bla %d ble %s\\n",
- PyInt_AsLong(PyTuple_GetItem(args, 0)),
+ PyLong_AsLong(PyTuple_GetItem(args, 0)),
_PyUnicode_AsString(PyTuple_GetItem(args, 1)));
'''
)
More information about the pypy-commit
mailing list