1. Wubin Qu
  2. pypy

Commits

Armin Rigo  committed 2071a44

issue1242 resolved

Fix for the ctypes "use_last_error=True" on non-Windows platforms.

  • Participants
  • Parent commits 5b12e8d
  • Branches default

Comments (0)

Files changed (2)

File pypy/module/_rawffi/__init__.py

View file
         'get_libc'           : 'interp_rawffi.get_libc',
         'get_errno'          : 'interp_rawffi.get_errno',
         'set_errno'          : 'interp_rawffi.set_errno',
+        'get_last_error'     : 'interp_rawffi.get_last_error',
+        'set_last_error'     : 'interp_rawffi.set_last_error',
         'SegfaultException'  : 'space.new_exception_class("_rawffi.SegfaultException")',
     }
 
-    if sys.platform == 'win32':
-        interpleveldefs['get_last_error'] = 'interp_rawffi.get_last_error'
-        interpleveldefs['set_last_error'] = 'interp_rawffi.set_last_error'
-
     appleveldefs = {
     }
 

File pypy/module/_rawffi/interp_rawffi.py

View file
 def set_errno(space, w_errno):
     rposix.set_errno(space.int_w(w_errno))
 
-def get_last_error(space):
-    from pypy.rlib.rwin32 import GetLastError
-    return space.wrap(GetLastError())
-
-@unwrap_spec(error=int)
-def set_last_error(space, error):
-    from pypy.rlib.rwin32 import SetLastError
-    SetLastError(error)
+if sys.platform == 'win32':
+    def get_last_error(space):
+        from pypy.rlib.rwin32 import GetLastError
+        return space.wrap(GetLastError())
+    @unwrap_spec(error=int)
+    def set_last_error(space, error):
+        from pypy.rlib.rwin32 import SetLastError
+        SetLastError(error)
+else:
+    # always have at least a dummy version of these functions
+    # (https://bugs.pypy.org/issue1242)
+    def get_last_error(space):
+        return space.wrap(0)
+    @unwrap_spec(error=int)
+    def set_last_error(space, error):
+        pass