[pypy-commit] pypy msvcrt-cffi: More fixing

arigo pypy.commits at gmail.com
Sun Jul 17 11:47:03 EDT 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: msvcrt-cffi
Changeset: r85739:5e07aae6b97d
Date: 2016-07-17 17:48 +0200
http://bitbucket.org/pypy/pypy/changeset/5e07aae6b97d/

Log:	More fixing

diff --git a/lib_pypy/_subprocess.py b/lib_pypy/_subprocess.py
--- a/lib_pypy/_subprocess.py
+++ b/lib_pypy/_subprocess.py
@@ -27,7 +27,9 @@
 class _handle(object):
     def __init__(self, c_handle):
         # 'c_handle' is a cffi cdata of type HANDLE, which is basically 'void *'
-        self.c_handle = _ffi.gc(c_handle, _kernel32.CloseHandle)
+        self.c_handle = c_handle
+        if int(self) != -1:
+            self.c_handle = _ffi.gc(self.c_handle, _kernel32.CloseHandle)
 
     def __int__(self):
         return int(_ffi.cast("intptr_t", self.c_handle))
@@ -111,17 +113,19 @@
     return _handle(pi.hProcess), _handle(pi.hThread), pi.dwProcessId, pi.dwThreadId
 
 def WaitForSingleObject(handle, milliseconds):
-    res = _kernel32.WaitForSingleObject(int(handle), milliseconds)
-
+    # CPython: the first argument is expected to be an integer.
+    res = _kernel32.WaitForSingleObject(_ffi.cast("HANDLE", handle),
+                                        milliseconds)
     if res < 0:
         raise _WinError()
 
     return res
 
 def GetExitCodeProcess(handle):
+    # CPython: the first argument is expected to be an integer.
     code = _ffi.new("DWORD[1]")
 
-    res = _kernel32.GetExitCodeProcess(int(handle), code)
+    res = _kernel32.GetExitCodeProcess(_ffi.cast("HANDLE", handle), code)
 
     if not res:
         raise _WinError()
diff --git a/lib_pypy/msvcrt.py b/lib_pypy/msvcrt.py
--- a/lib_pypy/msvcrt.py
+++ b/lib_pypy/msvcrt.py
@@ -13,8 +13,9 @@
 if sys.platform != 'win32':
     raise ImportError("The 'msvcrt' module is only available on Windows")
 
+import _rawffi
 from _pypy_winbase_cffi import ffi as _ffi
-_lib = _ffi.dlopen('msvcrt')
+_lib = _ffi.dlopen(_rawffi.get_libc().name)
 
 import errno
 
diff --git a/pypy/module/thread/gil.py b/pypy/module/thread/gil.py
--- a/pypy/module/thread/gil.py
+++ b/pypy/module/thread/gil.py
@@ -24,7 +24,6 @@
 
     def setup_threads(self, space):
         """Enable threads in the object space, if they haven't already been."""
-        import pdb;pdb.set_trace()
         if not self.gil_ready:
             # Note: this is a quasi-immutable read by module/pypyjit/interp_jit
             # It must be changed (to True) only if it was really False before


More information about the pypy-commit mailing list