summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-09-16 05:57:46 (GMT)
committerGitHub <noreply@github.com>2018-09-16 05:57:46 (GMT)
commite53632019816749ffd5be0afab2a99d744dbbe35 (patch)
tree3249d439260af52845564254c957b25b9f3c9c16 /Lib
parent03d8e7c02ddf79ca4a9ef2c9674d4ee2dec7c3c2 (diff)
downloadcpython-e53632019816749ffd5be0afab2a99d744dbbe35.zip
cpython-e53632019816749ffd5be0afab2a99d744dbbe35.tar.gz
cpython-e53632019816749ffd5be0afab2a99d744dbbe35.tar.bz2
bpo-34603, ctypes/libffi_msvc: Fix returning structs from functions (GH-9258)
(cherry picked from commit 7843caeb909bd907e903606414e238db4082315a) Co-authored-by: Vladimir Matveev <v2matveev@outlook.com>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/ctypes/test/test_win32.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_win32.py b/Lib/ctypes/test/test_win32.py
index 5d85ad6..ee72270 100644
--- a/Lib/ctypes/test/test_win32.py
+++ b/Lib/ctypes/test/test_win32.py
@@ -55,6 +55,24 @@ class FunctionCallTestCase(unittest.TestCase):
@unittest.skipUnless(sys.platform == "win32", 'Windows-specific test')
+class ReturnStructSizesTestCase(unittest.TestCase):
+ def test_sizes(self):
+ dll = CDLL(_ctypes_test.__file__)
+ for i in range(1, 11):
+ fields = [ (f"f{f}", c_char) for f in range(1, i + 1)]
+ class S(Structure):
+ _fields_ = fields
+ f = getattr(dll, f"TestSize{i}")
+ f.restype = S
+ res = f()
+ for i, f in enumerate(fields):
+ value = getattr(res, f[0])
+ expected = bytes([ord('a') + i])
+ self.assertEquals(value, expected)
+
+
+
+@unittest.skipUnless(sys.platform == "win32", 'Windows-specific test')
class TestWintypes(unittest.TestCase):
def test_HWND(self):
from ctypes import wintypes