[3.8] bpo-22273: Changed conditions for ctypes array-in-struct handli… · python/cpython@b92b8c5 (original) (raw)

`@@ -350,9 +350,7 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct

`

350

350

`int pack;

`

351

351

`Py_ssize_t ffi_ofs;

`

352

352

`int big_endian;

`

353

``

`-

#if defined(X86_64)

`

354

353

`int arrays_seen = 0;

`

355

``

`-

#endif

`

356

354

``

357

355

`/* HACK Alert: I cannot be bothered to fix ctypes.com, so there has to

`

358

356

` be a way to use the old, broken semantics: fields are not extended

`

`@@ -504,10 +502,8 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct

`

504

502

`Py_XDECREF(pair);

`

505

503

`return -1;

`

506

504

` }

`

507

``

`-

#if defined(X86_64)

`

508

505

`if (PyCArrayTypeObject_Check(desc))

`

509

506

`arrays_seen = 1;

`

510

``

`-

#endif

`

511

507

`dict = PyType_stgdict(desc);

`

512

508

`if (dict == NULL) {

`

513

509

`Py_DECREF(pair);

`

`@@ -648,8 +644,6 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct

`

648

644

`stgdict->align = total_align;

`

649

645

`stgdict->length = len; /* ADD ffi_ofs? */

`

650

646

``

651

``

`-

#if defined(X86_64)

`

652

``

-

653

647

`#define MAX_ELEMENTS 16

`

654

648

``

655

649

`if (arrays_seen && (size <= 16)) {

`

`@@ -669,6 +663,10 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct

`

669

663

` * accurate set, to allow libffi to marshal them into registers

`

670

664

` * correctly. It means one more loop over the fields, but if we got

`

671

665

` * here, the structure is small, so there aren't too many of those.

`

``

666

`+

`

``

667

`+

`

``

668

`+

`

``

669

`+

`

672

670

` */

`

673

671

`ffi_type *actual_types[MAX_ELEMENTS + 1];

`

674

672

`int actual_type_index = 0;

`

`@@ -746,7 +744,6 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct

`

746

744

`memcpy(&stgdict->ffi_type_pointer.elements[ffi_ofs], actual_types,

`

747

745

`actual_type_index * sizeof(ffi_type *));

`

748

746

` }

`

749

``

`-

#endif

`

750

747

``

751

748

`/* We did check that this flag was NOT set above, it must not

`

752

749

` have been set until now. */

`