|
|
6297a26 |
From 9dbf5d3bc2033940cdca35440cf08814544f81e4 Mon Sep 17 00:00:00 2001
|
|
|
6297a26 |
From: Vinay Sajip <vinay_sajip@yahoo.co.uk>
|
|
|
6297a26 |
Date: Sun, 12 Jan 2020 20:55:54 +0000
|
|
|
6297a26 |
Subject: [PATCH] [3.7] bpo-16575: Disabled checks for union types being passed
|
|
|
6297a26 |
by value. (GH-17960) (GH-17970)
|
|
|
6297a26 |
|
|
|
6297a26 |
Although the underlying libffi issue remains open, adding these
|
|
|
6297a26 |
checks have caused problems in third-party projects which are in
|
|
|
6297a26 |
widespread use. See the issue for examples.
|
|
|
6297a26 |
|
|
|
6297a26 |
The corresponding tests have also been skipped.
|
|
|
6297a26 |
(cherry picked from commit c12440c371025bea9c3bfb94945f006c486c2c01)
|
|
|
6297a26 |
---
|
|
|
6297a26 |
Lib/ctypes/test/test_structures.py | 3 ++-
|
|
|
6297a26 |
Modules/_ctypes/_ctypes.c | 19 +++++++++++++++++++
|
|
|
6297a26 |
2 files changed, 21 insertions(+), 1 deletion(-)
|
|
|
6297a26 |
|
|
|
6297a26 |
diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py
|
|
|
6297a26 |
index c129377041f03..2eb057a9f3009 100644
|
|
|
6297a26 |
--- a/Lib/ctypes/test/test_structures.py
|
|
|
6297a26 |
+++ b/Lib/ctypes/test/test_structures.py
|
|
|
6297a26 |
@@ -532,6 +532,7 @@ class U(Union):
|
|
|
6297a26 |
self.assertEqual(f2, [0x4567, 0x0123, 0xcdef, 0x89ab,
|
|
|
6297a26 |
0x3210, 0x7654, 0xba98, 0xfedc])
|
|
|
6297a26 |
|
|
|
6297a26 |
+ @unittest.skipIf(True, 'Test disabled for now - see bpo-16575/bpo-16576')
|
|
|
6297a26 |
def test_union_by_value(self):
|
|
|
6297a26 |
# See bpo-16575
|
|
|
6297a26 |
|
|
|
6297a26 |
@@ -612,7 +613,7 @@ class Test5(Structure):
|
|
|
6297a26 |
self.assertEqual(test5.nested.an_int, 0)
|
|
|
6297a26 |
self.assertEqual(test5.another_int, 0)
|
|
|
6297a26 |
|
|
|
6297a26 |
- #@unittest.skipIf('s390' in MACHINE, 'Test causes segfault on S390')
|
|
|
6297a26 |
+ @unittest.skipIf(True, 'Test disabled for now - see bpo-16575/bpo-16576')
|
|
|
6297a26 |
def test_bitfield_by_value(self):
|
|
|
6297a26 |
# See bpo-16576
|
|
|
6297a26 |
|
|
|
6297a26 |
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
|
|
|
6297a26 |
index c8fed44599543..dd0c61fd8a9a9 100644
|
|
|
6297a26 |
--- a/Modules/_ctypes/_ctypes.c
|
|
|
6297a26 |
+++ b/Modules/_ctypes/_ctypes.c
|
|
|
6297a26 |
@@ -2277,6 +2277,23 @@ converters_from_argtypes(PyObject *ob)
|
|
|
6297a26 |
for (i = 0; i < nArgs; ++i) {
|
|
|
6297a26 |
PyObject *tp = PyTuple_GET_ITEM(ob, i);
|
|
|
6297a26 |
PyObject *cnv;
|
|
|
6297a26 |
+/*
|
|
|
6297a26 |
+ * The following checks, relating to bpo-16575 and bpo-16576, have been
|
|
|
6297a26 |
+ * disabled. The reason is that, although there is a definite problem with
|
|
|
6297a26 |
+ * how libffi handles unions (https://github.com/libffi/libffi/issues/33),
|
|
|
6297a26 |
+ * there are numerous libraries which pass structures containing unions
|
|
|
6297a26 |
+ * by values - especially on Windows but examples also exist on Linux
|
|
|
6297a26 |
+ * (https://bugs.python.org/msg359834).
|
|
|
6297a26 |
+ *
|
|
|
6297a26 |
+ * It may not be possible to get proper support for unions and bitfields
|
|
|
6297a26 |
+ * until support is forthcoming in libffi, but for now, adding the checks
|
|
|
6297a26 |
+ * has caused problems in otherwise-working software, which suggests it
|
|
|
6297a26 |
+ * is better to disable the checks.
|
|
|
6297a26 |
+ *
|
|
|
6297a26 |
+ * Although specific examples reported relate specifically to unions and
|
|
|
6297a26 |
+ * not bitfields, the bitfields check is also being disabled as a
|
|
|
6297a26 |
+ * precaution.
|
|
|
6297a26 |
+
|
|
|
6297a26 |
StgDictObject *stgdict = PyType_stgdict(tp);
|
|
|
6297a26 |
|
|
|
6297a26 |
if (stgdict != NULL) {
|
|
|
6297a26 |
@@ -2304,6 +2321,8 @@ converters_from_argtypes(PyObject *ob)
|
|
|
6297a26 |
return NULL;
|
|
|
6297a26 |
}
|
|
|
6297a26 |
}
|
|
|
6297a26 |
+ */
|
|
|
6297a26 |
+
|
|
|
6297a26 |
cnv = PyObject_GetAttrString(tp, "from_param");
|
|
|
6297a26 |
if (!cnv)
|
|
|
6297a26 |
goto argtypes_error_1;
|