[ctypes-commit] ctypes/ctypes/test test_prototypes.py,1.3,1.4
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2006-04-13 18:15:31
|
Update of /cvsroot/ctypes/ctypes/ctypes/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7296 Modified Files: test_prototypes.py Log Message: Merge in changes made in Python SVN. Index: test_prototypes.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/test/test_prototypes.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_prototypes.py 14 Mar 2006 19:09:21 -0000 1.3 --- test_prototypes.py 13 Apr 2006 18:15:24 -0000 1.4 *************** *** 25,28 **** --- 25,41 ---- testdll = cdll.load(_ctypes_test.__file__) + # Return machine address `a` as a (possibly long) non-negative integer. + # Starting with Python 2.5, id(anything) is always non-negative, and + # the ctypes addressof() inherits that via PyLong_FromVoidPtr(). + def positive_address(a): + if a >= 0: + return a + # View the bits in `a` as unsigned instead. + import struct + num_bits = struct.calcsize("P") * 8 # num bits in native machine address + a += 1L << num_bits + assert a >= 0 + return a + def c_wbuffer(init): n = len(init) + 1 *************** *** 44,48 **** func.argtypes = POINTER(c_int), ! self.failUnlessEqual(addressof(ci), func(byref(ci))) func.argtypes = c_char_p, --- 57,62 ---- func.argtypes = POINTER(c_int), ! self.failUnlessEqual(positive_address(addressof(ci)), ! positive_address(func(byref(ci)))) func.argtypes = c_char_p, |