Update of /cvsroot/pywin32/pywin32/win32/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16738/test
Modified Files:
handles.py
Log Message:
ensure longs that can fit in 32 unsigned bits can be used as a handle
Index: handles.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/test/handles.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** handles.py 23 Oct 2003 04:09:56 -0000 1.3
--- handles.py 30 Oct 2007 09:53:32 -0000 1.4
***************
*** 1,2 ****
--- 1,3 ----
+ import sys
import unittest
import pywintypes
***************
*** 68,71 ****
--- 69,93 ----
self.assertRaises(win32api.error, h.Close)
+ def testOtherHandle(self):
+ h=pywintypes.HANDLE(1)
+ h2=pywintypes.HANDLE(h)
+ self.failUnlessEqual(h, h2)
+ # but the above doesn't really test everything - we want a way to
+ # pass the handle directly into PyWinLong_AsVoidPtr. One way to
+ # to that is to abuse win32api.GetProcAddress() - the 2nd param
+ # is passed to PyWinLong_AsVoidPtr() if its not a string.
+ # passing a handle value of '1' should work - there is something
+ # at that ordinal
+ win32api.GetProcAddress(sys.dllhandle, h)
+
+ def testLong(self):
+ # sys.maxint+1 should always be a 'valid' handle, treated as an
+ # unsigned int, even though it is a long. Although pywin32 should not
+ # directly create such longs, using struct.unpack() with a P format
+ # may well return them. eg:
+ # >>> struct.unpack("P", struct.pack("P", -1))
+ # (4294967295L,)
+ pywintypes.HANDLE(sys.maxint+1)
+
def testGC(self):
# This used to provoke:
|