Author: andrewjlawrence
Branch: winoverlapped
Changeset: r96372:79630c7e2718
Date: 2019-03-28 07:46 +0000
http://bitbucket.org/pypy/pypy/changeset/79630c7e2718/

Log:    Fixed exception types produced by overlapped.getresult, reverted
        rwin32.py

diff --git a/lib_pypy/_overlapped.py b/lib_pypy/_overlapped.py
--- a/lib_pypy/_overlapped.py
+++ b/lib_pypy/_overlapped.py
@@ -207,7 +207,7 @@
 
         if err != _winapi.ERROR_SUCCESS and err != _winapi.ERROR_MORE_DATA:
             if not (err == _winapi.ERROR_BROKEN_PIPE and (self.type in 
[OverlappedType.TYPE_READ, OverlappedType.TYPE_READINTO])):
-                raise _winapi._WinError()
+                SetFromWindowsErr(err)
 
         if self.type == OverlappedType.TYPE_READ:
             return _ffi.unpack(self.read_buffer, transferred[0])
@@ -578,8 +578,16 @@
 
 # In CPython this function converts a windows error into a python object
 # Not sure what we should do here.
-def SetFromWindowsErr(error):
-    return error
+def SetFromWindowsErr(err):
+    if err == _winapi.ERROR_CONNECTION_REFUSED:
+        type = ConnectionRefusedError;
+    elif err == _winapi.ERROR_CONNECTION_ABORTED:
+        type = ConnectionAbortedError;
+    else:
+        type = WindowsError;
+
+    return _winapi._WinError(type);
+
 
 def HasOverlappedIoCompleted(overlapped):
     return (overlapped.Internal != STATUS_PENDING)
diff --git a/lib_pypy/_winapi.py b/lib_pypy/_winapi.py
--- a/lib_pypy/_winapi.py
+++ b/lib_pypy/_winapi.py
@@ -19,9 +19,9 @@
 # Now the _subprocess module implementation
 
 
-def _WinError():
+def _WinError(type=WindowsError):
     code, message = _ffi.getwinerror()
-    excep = WindowsError(None, message, None ,code)
+    excep = type(None, message, None ,code)
     raise excep
 
 def _int2handle(val):
@@ -303,7 +303,7 @@
 ERROR_OPERATION_ABORTED = 995
 ERROR_IO_INCOMPLETE     = 996
 ERROR_IO_PENDING        = 997
-
+ERROR_CONNECTION_REFUSED = 1225
 
 PIPE_ACCESS_INBOUND = 0x00000001
 PIPE_ACCESS_OUTBOUND = 0x00000002
diff --git a/rpython/rlib/rwin32.py b/rpython/rlib/rwin32.py
--- a/rpython/rlib/rwin32.py
+++ b/rpython/rlib/rwin32.py
@@ -261,7 +261,7 @@
                 132: 13, 145: 41, 158: 13, 161: 2, 164: 11, 167: 13, 183: 17,
                 188: 8, 189: 8, 190: 8, 191: 8, 192: 8, 193: 8, 194: 8,
                 195: 8, 196: 8, 197: 8, 198: 8, 199: 8, 200: 8, 201: 8,
-                202: 8, 206: 2, 215: 11, 232: 32, 267: 20, 1816: 12, 1225: 111,
+                202: 8, 206: 2, 215: 11, 232: 32, 267: 20, 1816: 12, 
                 }
         return errors, errno.EINVAL
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to