|
|
acf2f58 |
From 812479ed6c2c7854f5fafb2366d005845bfff67a Mon Sep 17 00:00:00 2001
|
|
|
acf2f58 |
From: "Miss Islington (bot)"
|
|
|
acf2f58 |
<31488909+miss-islington@users.noreply.github.com>
|
|
|
acf2f58 |
Date: Sun, 12 Jan 2020 03:41:07 -0800
|
|
|
acf2f58 |
Subject: [PATCH] 00339: bpo-16575: Disabled checks for union types being
|
|
|
acf2f58 |
passed by value
|
|
|
acf2f58 |
|
|
|
acf2f58 |
Although the underlying libffi issue remains open, adding these
|
|
|
acf2f58 |
checks have caused problems in third-party projects which are in
|
|
|
acf2f58 |
widespread use. See the issue for examples.
|
|
|
acf2f58 |
|
|
|
acf2f58 |
The corresponding tests have also been skipped.
|
|
|
acf2f58 |
|
|
|
acf2f58 |
(cherry picked from commit c12440c371025bea9c3bfb94945f006c486c2c01)
|
|
|
acf2f58 |
---
|
|
|
acf2f58 |
Lib/ctypes/test/test_structures.py | 3 ++-
|
|
|
acf2f58 |
Modules/_ctypes/_ctypes.c | 18 ++++++++++++++++++
|
|
|
acf2f58 |
2 files changed, 20 insertions(+), 1 deletion(-)
|
|
|
acf2f58 |
|
|
|
acf2f58 |
diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py
|
|
|
acf2f58 |
index 19c4430bea..cdbaa7fbd6 100644
|
|
|
acf2f58 |
--- a/Lib/ctypes/test/test_structures.py
|
|
|
acf2f58 |
+++ b/Lib/ctypes/test/test_structures.py
|
|
|
acf2f58 |
@@ -571,6 +571,7 @@ class StructureTestCase(unittest.TestCase):
|
|
|
acf2f58 |
self.assertEqual(f2, [0x4567, 0x0123, 0xcdef, 0x89ab,
|
|
|
acf2f58 |
0x3210, 0x7654, 0xba98, 0xfedc])
|
|
|
acf2f58 |
|
|
|
acf2f58 |
+ @unittest.skipIf(True, 'Test disabled for now - see bpo-16575/bpo-16576')
|
|
|
acf2f58 |
def test_union_by_value(self):
|
|
|
acf2f58 |
# See bpo-16575
|
|
|
acf2f58 |
|
|
|
acf2f58 |
@@ -651,7 +652,7 @@ class StructureTestCase(unittest.TestCase):
|
|
|
acf2f58 |
self.assertEqual(test5.nested.an_int, 0)
|
|
|
acf2f58 |
self.assertEqual(test5.another_int, 0)
|
|
|
acf2f58 |
|
|
|
acf2f58 |
- #@unittest.skipIf('s390' in MACHINE, 'Test causes segfault on S390')
|
|
|
acf2f58 |
+ @unittest.skipIf(True, 'Test disabled for now - see bpo-16575/bpo-16576')
|
|
|
acf2f58 |
def test_bitfield_by_value(self):
|
|
|
acf2f58 |
# See bpo-16576
|
|
|
acf2f58 |
|
|
|
acf2f58 |
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
|
|
|
acf2f58 |
index 347a3656b6..b51fcde364 100644
|
|
|
acf2f58 |
--- a/Modules/_ctypes/_ctypes.c
|
|
|
acf2f58 |
+++ b/Modules/_ctypes/_ctypes.c
|
|
|
acf2f58 |
@@ -2401,6 +2401,23 @@ converters_from_argtypes(PyObject *ob)
|
|
|
acf2f58 |
for (i = 0; i < nArgs; ++i) {
|
|
|
acf2f58 |
PyObject *cnv;
|
|
|
acf2f58 |
PyObject *tp = PyTuple_GET_ITEM(ob, i);
|
|
|
acf2f58 |
+/*
|
|
|
acf2f58 |
+ * The following checks, relating to bpo-16575 and bpo-16576, have been
|
|
|
acf2f58 |
+ * disabled. The reason is that, although there is a definite problem with
|
|
|
acf2f58 |
+ * how libffi handles unions (https://github.com/libffi/libffi/issues/33),
|
|
|
acf2f58 |
+ * there are numerous libraries which pass structures containing unions
|
|
|
acf2f58 |
+ * by values - especially on Windows but examples also exist on Linux
|
|
|
acf2f58 |
+ * (https://bugs.python.org/msg359834).
|
|
|
acf2f58 |
+ *
|
|
|
acf2f58 |
+ * It may not be possible to get proper support for unions and bitfields
|
|
|
acf2f58 |
+ * until support is forthcoming in libffi, but for now, adding the checks
|
|
|
acf2f58 |
+ * has caused problems in otherwise-working software, which suggests it
|
|
|
acf2f58 |
+ * is better to disable the checks.
|
|
|
acf2f58 |
+ *
|
|
|
acf2f58 |
+ * Although specific examples reported relate specifically to unions and
|
|
|
acf2f58 |
+ * not bitfields, the bitfields check is also being disabled as a
|
|
|
acf2f58 |
+ * precaution.
|
|
|
acf2f58 |
+
|
|
|
acf2f58 |
StgDictObject *stgdict = PyType_stgdict(tp);
|
|
|
acf2f58 |
|
|
|
acf2f58 |
if (stgdict != NULL) {
|
|
|
acf2f58 |
@@ -2428,6 +2445,7 @@ converters_from_argtypes(PyObject *ob)
|
|
|
acf2f58 |
return NULL;
|
|
|
acf2f58 |
}
|
|
|
acf2f58 |
}
|
|
|
acf2f58 |
+ */
|
|
|
acf2f58 |
|
|
|
acf2f58 |
if (_PyObject_LookupAttrId(tp, &PyId_from_param, &cnv) <= 0) {
|
|
|
acf2f58 |
Py_DECREF(converters);
|
|
|
acf2f58 |
--
|
|
|
acf2f58 |
2.24.1
|
|
|
acf2f58 |
|