Author: Ronan Lamy <[email protected]>
Branch:
Changeset: r89675:e83a89914c1b
Date: 2017-01-20 00:31 +0000
http://bitbucket.org/pypy/pypy/changeset/e83a89914c1b/
Log: Typedef Py_ssize_t to long as it's (hopefully, maybe?) the right
size on all supported platforms
diff --git a/pypy/module/cpyext/include/object.h
b/pypy/module/cpyext/include/object.h
--- a/pypy/module/cpyext/include/object.h
+++ b/pypy/module/cpyext/include/object.h
@@ -7,14 +7,7 @@
extern "C" {
#endif
-/* Hack: MSVC doesn't support ssize_t */
-#ifdef _WIN32
-#define ssize_t long
-#endif
#include <cpyext_object.h>
-#ifdef _WIN32
-#undef ssize_t
-#endif
#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1))
#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
diff --git a/pypy/module/cpyext/parse/cpyext_object.h
b/pypy/module/cpyext/parse/cpyext_object.h
--- a/pypy/module/cpyext/parse/cpyext_object.h
+++ b/pypy/module/cpyext/parse/cpyext_object.h
@@ -1,5 +1,5 @@
-typedef ssize_t Py_ssize_t;
+typedef long Py_ssize_t;
#define PyObject_HEAD \
Py_ssize_t ob_refcnt; \
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
@@ -12,13 +12,13 @@
PyObject *t = PyTuple_New(1);
PyObject *f = PyFloat_FromDouble(42.0);
PyObject *g = NULL;
- printf("Refcnt1: %zd\\n", f->ob_refcnt);
+ printf("Refcnt1: %ld\\n", f->ob_refcnt);
PyTuple_SetItem(t, 0, f); // steals reference
- printf("Refcnt2: %zd\\n", f->ob_refcnt);
+ printf("Refcnt2: %ld\\n", f->ob_refcnt);
f = PyTuple_GetItem(t, 0); // borrows reference
- printf("Refcnt3: %zd\\n", f->ob_refcnt);
+ printf("Refcnt3: %ld\\n", f->ob_refcnt);
g = PyTuple_GetItem(t, 0); // borrows reference again
- printf("Refcnt4: %zd\\n", f->ob_refcnt);
+ printf("Refcnt4: %ld\\n", f->ob_refcnt);
printf("COMPARE: %i\\n", f == g);
fflush(stdout);
Py_DECREF(t);
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
@@ -646,7 +646,7 @@
refcnt_after = true_obj->ob_refcnt;
Py_DECREF(true_obj);
Py_DECREF(true_obj);
- fprintf(stderr, "REFCNT %zd %zd\\n", refcnt, refcnt_after);
+ fprintf(stderr, "REFCNT %ld %ld\\n", refcnt, refcnt_after);
return PyBool_FromLong(refcnt_after == refcnt + 2);
}
static PyObject* foo_bar(PyObject* self, PyObject *args)
@@ -662,7 +662,7 @@
return NULL;
refcnt_after = true_obj->ob_refcnt;
Py_DECREF(tup);
- fprintf(stderr, "REFCNT2 %zd %zd %zd\\n", refcnt, refcnt_after,
+ fprintf(stderr, "REFCNT2 %ld %ld %ld\\n", refcnt, refcnt_after,
true_obj->ob_refcnt);
return PyBool_FromLong(refcnt_after == refcnt + 1 &&
refcnt == true_obj->ob_refcnt);
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit