[pypy-commit] pypy default: windows fixes

arigo pypy.commits at gmail.com
Tue Mar 14 03:48:21 EDT 2017


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r90670:7593b2f6ba5f
Date: 2017-03-14 08:47 +0100
http://bitbucket.org/pypy/pypy/changeset/7593b2f6ba5f/

Log:	windows fixes

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
@@ -73,6 +73,7 @@
                 ("dance", "METH_NOARGS",
                  """
                      PyThreadState *old_tstate, *new_tstate;
+                     PyObject *d;
 
                      PyEval_InitThreads();
 
@@ -81,7 +82,7 @@
                          return PyLong_FromLong(0);
                      }
 
-                     PyObject* d = PyThreadState_GetDict(); /* fails on cpython */
+                     d = PyThreadState_GetDict(); /* fails on cpython */
                      if (d != NULL) {
                          return PyLong_FromLong(1);
                      }
@@ -144,6 +145,9 @@
             ("bounce", "METH_NOARGS",
             """
             PyThreadState * tstate;
+            PyObject *dict;
+            PyGILState_STATE gilstate;
+
             if (PyEval_ThreadsInitialized() == 0)
             {
             PyEval_InitThreads();
@@ -152,11 +156,11 @@
             if (tstate == NULL) {
                 return PyLong_FromLong(0);
             }
-            PyObject* dict = PyThreadState_GetDict();
+            dict = PyThreadState_GetDict();
             if (dict != NULL) {
             return PyLong_FromLong(1);
             }
-            PyGILState_STATE gilstate = PyGILState_Ensure();
+            gilstate = PyGILState_Ensure();
             dict = PyThreadState_GetDict();
             if (dict == NULL) {
             return PyLong_FromLong(2);
diff --git a/pypy/module/cpyext/test/test_userslots.py b/pypy/module/cpyext/test/test_userslots.py
--- a/pypy/module/cpyext/test/test_userslots.py
+++ b/pypy/module/cpyext/test/test_userslots.py
@@ -160,8 +160,9 @@
                 };
             ''', more_init='''
                 PyObject * mod = PyImport_ImportModule("datetime");
+                PyObject * dt;
                 if (mod == NULL) INITERROR;
-                PyObject * dt = PyString_FromString("datetime");
+                dt = PyString_FromString("datetime");
                 datetime_cls = (PyTypeObject*)PyObject_GetAttr(mod, dt); 
                 if (datetime_cls == NULL) INITERROR;
                 _Timestamp.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -464,28 +464,29 @@
             how = SEEK_END
     return handle_posix_error('lseek', c_lseek(fd, pos, how))
 
-c_pread = external('pread',
-                  [rffi.INT, rffi.VOIDP, rffi.SIZE_T , OFF_T], rffi.SSIZE_T,
-                  save_err=rffi.RFFI_SAVE_ERRNO)
-c_pwrite = external('pwrite',
-                   [rffi.INT, rffi.VOIDP, rffi.SIZE_T, OFF_T], rffi.SSIZE_T,
-                   save_err=rffi.RFFI_SAVE_ERRNO)
+if not _WIN32:
+    c_pread = external('pread',
+                      [rffi.INT, rffi.VOIDP, rffi.SIZE_T , OFF_T], rffi.SSIZE_T,
+                      save_err=rffi.RFFI_SAVE_ERRNO)
+    c_pwrite = external('pwrite',
+                       [rffi.INT, rffi.VOIDP, rffi.SIZE_T, OFF_T], rffi.SSIZE_T,
+                       save_err=rffi.RFFI_SAVE_ERRNO)
 
- at enforceargs(int, int, None)
-def pread(fd, count, offset):
-    if count < 0:
-        raise OSError(errno.EINVAL, None)
-    validate_fd(fd)
-    with rffi.scoped_alloc_buffer(count) as buf:
-        void_buf = rffi.cast(rffi.VOIDP, buf.raw)
-        return buf.str(handle_posix_error('pread', c_pread(fd, void_buf, count, offset)))
-        
- at enforceargs(int, None, None)
-def pwrite(fd, data, offset):
-    count = len(data)
-    validate_fd(fd)
-    with rffi.scoped_nonmovingbuffer(data) as buf:
-        return handle_posix_error('pwrite', c_pwrite(fd, buf, count, offset))
+    @enforceargs(int, int, None)
+    def pread(fd, count, offset):
+        if count < 0:
+            raise OSError(errno.EINVAL, None)
+        validate_fd(fd)
+        with rffi.scoped_alloc_buffer(count) as buf:
+            void_buf = rffi.cast(rffi.VOIDP, buf.raw)
+            return buf.str(handle_posix_error('pread', c_pread(fd, void_buf, count, offset)))
+            
+    @enforceargs(int, None, None)
+    def pwrite(fd, data, offset):
+        count = len(data)
+        validate_fd(fd)
+        with rffi.scoped_nonmovingbuffer(data) as buf:
+            return handle_posix_error('pwrite', c_pwrite(fd, buf, count, offset))
 
 c_ftruncate = external('ftruncate', [rffi.INT, rffi.LONGLONG], rffi.INT,
                        macro=_MACRO_ON_POSIX, save_err=rffi.RFFI_SAVE_ERRNO)


More information about the pypy-commit mailing list