Author: Matti Picus <[email protected]>
Branch: cpyext-for-merge
Changeset: r83986:727b9be53899
Date: 2016-04-27 18:13 +0300
http://bitbucket.org/pypy/pypy/changeset/727b9be53899/
Log: fix for win32 and c90
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -87,13 +87,13 @@
FILEP = rffi.COpaquePtr('FILE')
if sys.platform == 'win32':
- fileno = rffi.llexternal('_fileno', [FILEP], rffi.INT)
+ dash = '_'
else:
- fileno = rffi.llexternal('fileno', [FILEP], rffi.INT)
-
+ dash = ''
+fileno = rffi.llexternal(dash + 'fileno', [FILEP], rffi.INT)
fopen = rffi.llexternal('fopen', [CONST_STRING, CONST_STRING], FILEP)
-fdopen = rffi.llexternal('fdopen', [rffi.INT, CONST_STRING], FILEP,
- save_err=rffi.RFFI_SAVE_ERRNO)
+fdopen = rffi.llexternal(dash + 'fdopen', [rffi.INT, CONST_STRING],
+ FILEP, save_err=rffi.RFFI_SAVE_ERRNO)
_fclose = rffi.llexternal('fclose', [FILEP], rffi.INT)
def fclose(fp):
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
@@ -141,13 +141,14 @@
module = self.import_extension('foo', [
("test_get_item", "METH_NOARGS",
"""
- PyObject* o = PyList_New(1);
+ PyObject* o, *o2, *o3;
+ o = PyList_New(1);
- PyObject* o2 = PyInt_FromLong(0);
+ o2 = PyInt_FromLong(0);
PyList_SET_ITEM(o, 0, o2);
o2 = NULL;
- PyObject* o3 = PyList_GET_ITEM(o, 0);
+ o3 = PyList_GET_ITEM(o, 0);
Py_INCREF(o3);
Py_CLEAR(o);
return o3;
@@ -161,16 +162,17 @@
"""
PyObject* o = PyList_New(0);
PyObject* o2 = PyList_New(0);
+ Py_ssize_t refcount, new_refcount;
PyList_Append(o, o2); // does not steal o2
- Py_ssize_t refcount = Py_REFCNT(o2);
+ refcount = Py_REFCNT(o2);
// Steal a reference to o2, but leak the old reference to o2.
// The net result should be no change in refcount.
PyList_SET_ITEM(o, 0, o2);
- Py_ssize_t new_refcount = Py_REFCNT(o2);
+ new_refcount = Py_REFCNT(o2);
Py_CLEAR(o);
Py_DECREF(o2); // append incref'd.
diff --git a/pypy/module/cpyext/test/test_pystate.py
b/pypy/module/cpyext/test/test_pystate.py
--- a/pypy/module/cpyext/test/test_pystate.py
+++ b/pypy/module/cpyext/test/test_pystate.py
@@ -118,12 +118,13 @@
module = self.import_extension('foo', [
("bounce", "METH_NOARGS",
"""
+ PyThreadState * tstate;
if (PyEval_ThreadsInitialized() == 0)
{
PyEval_InitThreads();
}
PyGILState_Ensure();
- PyThreadState *tstate = PyEval_SaveThread();
+ tstate = PyEval_SaveThread();
if (tstate == NULL) {
return PyLong_FromLong(0);
}
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit