summaryrefslogtreecommitdiff
path: root/Lib/ctypes
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2016-08-05 21:44:52 +0100
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2016-08-05 21:44:52 +0100
commit51be07490fe5f3d9b4b97d9463372eb38c9b8ae2 (patch)
treee5ac0b77110aa50ab0694a1e04ee93433a823969 /Lib/ctypes
parent1a68aad063b2b05dbcbe865f2fd8656f70ac7c89 (diff)
parent3d27a2eba1a45308cb43c3e187a772d44acb9c98 (diff)
downloadcpython-51be07490fe5f3d9b4b97d9463372eb38c9b8ae2.tar.gz
Closes #20160: Merged fix from 3.5.
Diffstat (limited to 'Lib/ctypes')
-rw-r--r--Lib/ctypes/test/test_callbacks.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_callbacks.py b/Lib/ctypes/test/test_callbacks.py
index 3824f7c9fd..8eac58f026 100644
--- a/Lib/ctypes/test/test_callbacks.py
+++ b/Lib/ctypes/test/test_callbacks.py
@@ -1,3 +1,4 @@
+import functools
import unittest
from ctypes import *
from ctypes.test import need_symbol
@@ -240,6 +241,40 @@ class SampleCallbacksTestCase(unittest.TestCase):
self.assertEqual(result,
callback(1.1*1.1, 2.2*2.2, 3.3*3.3, 4.4*4.4, 5.5*5.5))
+ def test_callback_large_struct(self):
+ class Check: pass
+
+ class X(Structure):
+ _fields_ = [
+ ('first', c_ulong),
+ ('second', c_ulong),
+ ('third', c_ulong),
+ ]
+
+ def callback(check, s):
+ check.first = s.first
+ check.second = s.second
+ check.third = s.third
+
+ check = Check()
+ s = X()
+ s.first = 0xdeadbeef
+ s.second = 0xcafebabe
+ s.third = 0x0bad1dea
+
+ CALLBACK = CFUNCTYPE(None, X)
+ dll = CDLL(_ctypes_test.__file__)
+ func = dll._testfunc_cbk_large_struct
+ func.argtypes = (X, CALLBACK)
+ func.restype = None
+ # the function just calls the callback with the passed structure
+ func(s, CALLBACK(functools.partial(callback, check)))
+ self.assertEqual(check.first, s.first)
+ self.assertEqual(check.second, s.second)
+ self.assertEqual(check.third, s.third)
+ self.assertEqual(check.first, 0xdeadbeef)
+ self.assertEqual(check.second, 0xcafebabe)
+ self.assertEqual(check.third, 0x0bad1dea)
################################################################