summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorErik Bray <erik.m.bray@gmail.com>2017-06-07 17:42:24 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2017-06-07 17:42:24 (GMT)
commit9ba3aa4d02a110d1a1ea464a8aff3be7dd9c63c3 (patch)
treeb9ffda17e8b2462c8a859531b645c79a473055f2 /Lib
parent897bba75632dfce87c355e3cd4700468357715a7 (diff)
downloadcpython-9ba3aa4d02a110d1a1ea464a8aff3be7dd9c63c3.zip
cpython-9ba3aa4d02a110d1a1ea464a8aff3be7dd9c63c3.tar.gz
cpython-9ba3aa4d02a110d1a1ea464a8aff3be7dd9c63c3.tar.bz2
bpo-30353: Fix pass by value for structs on 64-bit Cygwin/MinGW (GH-1559)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/ctypes/test/test_as_parameter.py4
-rw-r--r--Lib/ctypes/test/test_structures.py22
2 files changed, 26 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_as_parameter.py b/Lib/ctypes/test/test_as_parameter.py
index 2a3484b..a264057 100644
--- a/Lib/ctypes/test/test_as_parameter.py
+++ b/Lib/ctypes/test/test_as_parameter.py
@@ -169,6 +169,10 @@ class BasicWrapTestCase(unittest.TestCase):
s2h = dll.ret_2h_func(self.wrap(inp))
self.assertEqual((s2h.x, s2h.y), (99*2, 88*3))
+ # Test also that the original struct was unmodified (i.e. was passed by
+ # value)
+ self.assertEqual((inp.x, inp.y), (99, 88))
+
def test_struct_return_8H(self):
class S8I(Structure):
_fields_ = [("a", c_int),
diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py
index 2e778fb..d90c711 100644
--- a/Lib/ctypes/test/test_structures.py
+++ b/Lib/ctypes/test/test_structures.py
@@ -417,6 +417,28 @@ class StructureTestCase(unittest.TestCase):
self.assertEqual(s.second, 0xcafebabe)
self.assertEqual(s.third, 0x0bad1dea)
+ def test_pass_by_value_in_register(self):
+ class X(Structure):
+ _fields_ = [
+ ('first', c_uint),
+ ('second', c_uint)
+ ]
+
+ s = X()
+ s.first = 0xdeadbeef
+ s.second = 0xcafebabe
+ dll = CDLL(_ctypes_test.__file__)
+ func = dll._testfunc_reg_struct_update_value
+ func.argtypes = (X,)
+ func.restype = None
+ func(s)
+ self.assertEqual(s.first, 0xdeadbeef)
+ self.assertEqual(s.second, 0xcafebabe)
+ got = X.in_dll(dll, "last_tfrsuv_arg")
+ self.assertEqual(s.first, got.first)
+ self.assertEqual(s.second, got.second)
+
+
class PointerMemberTestCase(unittest.TestCase):
def test(self):