Author: Armin Rigo <[email protected]>
Branch: msvcrt-cffi
Changeset: r85740:e5ff527a2054
Date: 2016-07-17 18:29 +0200
http://bitbucket.org/pypy/pypy/changeset/e5ff527a2054/
Log: Fix: GetStdHandle() must not free the handle it returns
diff --git a/lib_pypy/_subprocess.py b/lib_pypy/_subprocess.py
--- a/lib_pypy/_subprocess.py
+++ b/lib_pypy/_subprocess.py
@@ -34,18 +34,23 @@
def __int__(self):
return int(_ffi.cast("intptr_t", self.c_handle))
+ def __repr__(self):
+ return '<_subprocess.handle %d at 0x%x>' % (int(self), id(self))
+
def Detach(self):
h = int(self)
if h != -1:
- _ffi.gc(self.c_handle, None)
+ c_handle = self.c_handle
self.c_handle = _INVALID_HANDLE_VALUE
+ _ffi.gc(c_handle, None)
return h
def Close(self):
if int(self) != -1:
- _kernel32.CloseHandle(self.c_handle)
- _ffi.gc(self.c_handle, None)
+ c_handle = self.c_handle
self.c_handle = _INVALID_HANDLE_VALUE
+ _ffi.gc(c_handle, None)
+ _kernel32.CloseHandle(c_handle)
def CreatePipe(attributes, size):
handles = _ffi.new("HANDLE[2]")
@@ -149,7 +154,7 @@
return None
else:
# note: returns integer, not handle object
- return int(_handle(res))
+ return int(_ffi.cast("intptr_t", res))
STD_INPUT_HANDLE = -10
STD_OUTPUT_HANDLE = -11
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit