summaryrefslogtreecommitdiffstats
path: root/Lib/ctypes
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2014-11-06 03:16:05 (GMT)
committerSteve Dower <steve.dower@microsoft.com>2014-11-06 03:16:05 (GMT)
commit31221a7285938aae7cb98bffffe205c6e5bfe31c (patch)
treea78c5f040888ab27996cc4a500d4480c76849676 /Lib/ctypes
parenta1137fba8949d37da17f16c396a94e5df1e1f9b4 (diff)
downloadcpython-31221a7285938aae7cb98bffffe205c6e5bfe31c.zip
cpython-31221a7285938aae7cb98bffffe205c6e5bfe31c.tar.gz
cpython-31221a7285938aae7cb98bffffe205c6e5bfe31c.tar.bz2
Issue #20160: broken ctypes calling convention on MSVC / 64-bit Windows (large structs). Patch by mattip
Diffstat (limited to 'Lib/ctypes')
-rw-r--r--Lib/ctypes/test/test_win32.py26
1 files changed, 23 insertions, 3 deletions
diff --git a/Lib/ctypes/test/test_win32.py b/Lib/ctypes/test/test_win32.py
index 2dd7b45..ff08386 100644
--- a/Lib/ctypes/test/test_win32.py
+++ b/Lib/ctypes/test/test_win32.py
@@ -90,9 +90,29 @@ class Structures(unittest.TestCase):
dll = CDLL(_ctypes_test.__file__)
- pt = POINT(10, 10)
- rect = RECT(0, 0, 20, 20)
- self.assertEqual(1, dll.PointInRect(byref(rect), pt))
+ pt = POINT(15, 25)
+ left = c_long.in_dll(dll, 'left')
+ top = c_long.in_dll(dll, 'top')
+ right = c_long.in_dll(dll, 'right')
+ bottom = c_long.in_dll(dll, 'bottom')
+ rect = RECT(left, top, right, bottom)
+ PointInRect = dll.PointInRect
+ PointInRect.argtypes = [POINTER(RECT), POINT]
+ self.assertEqual(1, PointInRect(byref(rect), pt))
+
+ ReturnRect = dll.ReturnRect
+ ReturnRect.argtypes = [c_int, RECT, POINTER(RECT), POINT, RECT,
+ POINTER(RECT), POINT, RECT]
+ ReturnRect.restype = RECT
+ for i in range(4):
+ ret = ReturnRect(i, rect, pointer(rect), pt, rect,
+ byref(rect), pt, rect)
+ # the c function will check and modify ret if something is
+ # passed in improperly
+ self.assertEqual(ret.left, left.value)
+ self.assertEqual(ret.right, right.value)
+ self.assertEqual(ret.top, top.value)
+ self.assertEqual(ret.bottom, bottom.value)
if __name__ == '__main__':
unittest.main()