[pypy-commit] pypy default: #Issue 1030: (Akaiten) In _subprocess.py, use ctypes.WinError() to raise a WindowsError with the correct windows error code.

amauryfa noreply at buildbot.pypy.org
Sun Feb 12 20:16:06 CET 2012


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: 
Changeset: r52396:5e6014f89520
Date: 2012-02-12 20:14 +0100
http://bitbucket.org/pypy/pypy/changeset/5e6014f89520/

Log:	#Issue 1030: (Akaiten) In _subprocess.py, use ctypes.WinError() to
	raise a WindowsError with the correct windows error code. This fixes
	a test in test_subprocess.

diff --git a/lib_pypy/_subprocess.py b/lib_pypy/_subprocess.py
--- a/lib_pypy/_subprocess.py
+++ b/lib_pypy/_subprocess.py
@@ -87,7 +87,7 @@
 
 # Now the _subprocess module implementation 
 
-from ctypes import c_int as _c_int, byref as _byref
+from ctypes import c_int as _c_int, byref as _byref, WinError as _WinError
 
 class _handle:
     def __init__(self, handle):
@@ -116,7 +116,7 @@
     res = _CreatePipe(_byref(read), _byref(write), None, size)
 
     if not res:
-        raise WindowsError("Error")
+        raise _WinError()
 
     return _handle(read.value), _handle(write.value)
 
@@ -132,7 +132,7 @@
                            access, inherit, options)
 
     if not res:
-        raise WindowsError("Error")
+        raise _WinError()
 
     return _handle(target.value)
 DUPLICATE_SAME_ACCESS = 2
@@ -165,7 +165,7 @@
                         start_dir, _byref(si), _byref(pi))
 
     if not res:
-        raise WindowsError("Error")
+        raise _WinError()
 
     return _handle(pi.hProcess), _handle(pi.hThread), pi.dwProcessID, pi.dwThreadID
 STARTF_USESHOWWINDOW = 0x001
@@ -178,7 +178,7 @@
     res = _WaitForSingleObject(int(handle), milliseconds)
 
     if res < 0:
-        raise WindowsError("Error")
+        raise _WinError()
 
     return res
 INFINITE = 0xffffffff
@@ -190,7 +190,7 @@
     res = _GetExitCodeProcess(int(handle), _byref(code))
 
     if not res:
-        raise WindowsError("Error")
+        raise _WinError()
 
     return code.value
 
@@ -198,7 +198,7 @@
     res = _TerminateProcess(int(handle), exitcode)
 
     if not res:
-        raise WindowsError("Error")
+        raise _WinError()
 
 def GetStdHandle(stdhandle):
     res = _GetStdHandle(stdhandle)


More information about the pypy-commit mailing list