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

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

`

344

344

`int pack = 0;

`

345

345

`Py_ssize_t ffi_ofs;

`

346

346

`int big_endian;

`

347

``

`-

#if defined(X86_64)

`

348

347

`int arrays_seen = 0;

`

349

``

`-

#endif

`

350

348

``

351

349

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

`

352

350

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

`

`@@ -471,10 +469,8 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct

`

471

469

`Py_XDECREF(pair);

`

472

470

`return -1;

`

473

471

` }

`

474

``

`-

#if defined(X86_64)

`

475

472

`if (PyCArrayTypeObject_Check(desc))

`

476

473

`arrays_seen = 1;

`

477

``

`-

#endif

`

478

474

`dict = PyType_stgdict(desc);

`

479

475

`if (dict == NULL) {

`

480

476

`Py_DECREF(pair);

`

`@@ -615,8 +611,6 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct

`

615

611

`stgdict->align = total_align;

`

616

612

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

`

617

613

``

618

``

`-

#if defined(X86_64)

`

619

``

-

620

614

`#define MAX_ELEMENTS 16

`

621

615

``

622

616

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

`

`@@ -636,6 +630,10 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct

`

636

630

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

`

637

631

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

`

638

632

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

`

``

633

`+

`

``

634

`+

`

``

635

`+

`

``

636

`+

`

639

637

` */

`

640

638

`ffi_type *actual_types[MAX_ELEMENTS + 1];

`

641

639

`int actual_type_index = 0;

`

`@@ -713,7 +711,6 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct

`

713

711

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

`

714

712

`actual_type_index * sizeof(ffi_type *));

`

715

713

` }

`

716

``

`-

#endif

`

717

714

``

718

715

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

`

719

716

` have been set until now. */

`