Update of /cvsroot/pywin32/pywin32/win32/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18491/test
Modified Files:
test_win32file.py
Log Message:
Fix [ 1178513 ] Invalid handle with win32file.CreateIoCompletionPort
This function now correctly returns the existing handle when one is passed
Index: test_win32file.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32file.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** test_win32file.py 9 Oct 2004 01:42:01 -0000 1.5
--- test_win32file.py 12 Apr 2005 02:56:45 -0000 1.6
***************
*** 149,152 ****
--- 149,181 ----
h.Close()
+ def testCompletionPortsMultiple(self):
+ # Mainly checking that we can "associate" an existing handle. This
+ # failed in build 203.
+ import socket
+
+ ioport = win32file.CreateIoCompletionPort(win32file.INVALID_HANDLE_VALUE,
+ 0, 0, 0)
+ socks = []
+ for PORT in range(9123, 9125):
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+ sock.bind(('', PORT))
+ sock.listen(1)
+ socks.append(sock)
+ new = win32file.CreateIoCompletionPort(sock.fileno(), ioport, PORT, 0)
+ assert new is ioport
+ for s in socks:
+ s.close()
+ hv = int(ioport)
+ ioport = new = None
+ # The handle itself should be closed now (unless we leak references!)
+ # Check that.
+ try:
+ win32file.CloseHandle(hv)
+ raise RuntimeError, "Expected close to fail!"
+ except win32file.error, (hr, func, msg):
+ self.failUnlessEqual(hr, winerror.ERROR_INVALID_HANDLE)
+
+
class TestFindFiles(unittest.TestCase):
def testIter(self):
|