Skip to content

Commit 9dbf5d3

Browse files
authored
[3.7] bpo-16575: Disabled checks for union types being passed by value. (GH-17960) (GH-17970)
Although the underlying libffi issue remains open, adding these checks have caused problems in third-party projects which are in widespread use. See the issue for examples. The corresponding tests have also been skipped. (cherry picked from commit c12440c)
1 parent e222b4c commit 9dbf5d3

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Lib/ctypes/test/test_structures.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ class U(Union):
532532
self.assertEqual(f2, [0x4567, 0x0123, 0xcdef, 0x89ab,
533533
0x3210, 0x7654, 0xba98, 0xfedc])
534534

535+
@unittest.skipIf(True, 'Test disabled for now - see bpo-16575/bpo-16576')
535536
def test_union_by_value(self):
536537
# See bpo-16575
537538

@@ -612,7 +613,7 @@ class Test5(Structure):
612613
self.assertEqual(test5.nested.an_int, 0)
613614
self.assertEqual(test5.another_int, 0)
614615

615-
#@unittest.skipIf('s390' in MACHINE, 'Test causes segfault on S390')
616+
@unittest.skipIf(True, 'Test disabled for now - see bpo-16575/bpo-16576')
616617
def test_bitfield_by_value(self):
617618
# See bpo-16576
618619

Modules/_ctypes/_ctypes.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2277,6 +2277,23 @@ converters_from_argtypes(PyObject *ob)
22772277
for (i = 0; i < nArgs; ++i) {
22782278
PyObject *tp = PyTuple_GET_ITEM(ob, i);
22792279
PyObject *cnv;
2280+
/*
2281+
* The following checks, relating to bpo-16575 and bpo-16576, have been
2282+
* disabled. The reason is that, although there is a definite problem with
2283+
* how libffi handles unions (https://github.com/libffi/libffi/issues/33),
2284+
* there are numerous libraries which pass structures containing unions
2285+
* by values - especially on Windows but examples also exist on Linux
2286+
* (https://bugs.python.org/msg359834).
2287+
*
2288+
* It may not be possible to get proper support for unions and bitfields
2289+
* until support is forthcoming in libffi, but for now, adding the checks
2290+
* has caused problems in otherwise-working software, which suggests it
2291+
* is better to disable the checks.
2292+
*
2293+
* Although specific examples reported relate specifically to unions and
2294+
* not bitfields, the bitfields check is also being disabled as a
2295+
* precaution.
2296+
22802297
StgDictObject *stgdict = PyType_stgdict(tp);
22812298
22822299
if (stgdict != NULL) {
@@ -2304,6 +2321,8 @@ converters_from_argtypes(PyObject *ob)
23042321
return NULL;
23052322
}
23062323
}
2324+
*/
2325+
23072326
cnv = PyObject_GetAttrString(tp, "from_param");
23082327
if (!cnv)
23092328
goto argtypes_error_1;

0 commit comments

Comments
 (0)