Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a3360fa

Browse files
authored
gh-99284: [ctypes] remove _use_broken_old_ctypes_structure_semantics_ (GH-99285)
It was untested and undocumented. No code has been found in the wild that ever used it.
1 parent 27d8dc2 commit a3360fa

7 files changed

+7
-27
lines changed

Doc/whatsnew/3.12.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,3 +873,7 @@ Removed
873873
* Remove the ``PyUnicode_InternImmortal()`` function and the
874874
``SSTATE_INTERNED_IMMORTAL`` macro.
875875
(Contributed by Victor Stinner in :gh:`85858`.)
876+
877+
* Remove ``_use_broken_old_ctypes_structure_semantics_`` flag
878+
from :mod:`ctypes` module.
879+
(Contributed by Nikita Sobolev in :gh:`99285`.)

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ struct _Py_global_strings {
251251
STRUCT_FOR_ID(_swappedbytes_)
252252
STRUCT_FOR_ID(_type_)
253253
STRUCT_FOR_ID(_uninitialized_submodules)
254-
STRUCT_FOR_ID(_use_broken_old_ctypes_structure_semantics_)
255254
STRUCT_FOR_ID(_warn_unawaited_coroutine)
256255
STRUCT_FOR_ID(_xoptions)
257256
STRUCT_FOR_ID(a)

Include/internal/pycore_runtime_init_generated.h

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Remove ``_use_broken_old_ctypes_structure_semantics_``
2+
old untested and undocumented hack from :mod:`ctypes`.

Modules/_ctypes/stgdict.c

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -356,14 +356,6 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
356356
int big_endian;
357357
int arrays_seen = 0;
358358

359-
/* HACK Alert: I cannot be bothered to fix ctypes.com, so there has to
360-
be a way to use the old, broken semantics: _fields_ are not extended
361-
but replaced in subclasses.
362-
363-
XXX Remove this in ctypes 1.0!
364-
*/
365-
int use_broken_old_ctypes_semantics;
366-
367359
if (fields == NULL)
368360
return 0;
369361

@@ -378,19 +370,6 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
378370
big_endian = PY_BIG_ENDIAN;
379371
}
380372

381-
if (_PyObject_LookupAttr(type,
382-
&_Py_ID(_use_broken_old_ctypes_structure_semantics_), &tmp) < 0)
383-
{
384-
return -1;
385-
}
386-
if (tmp) {
387-
Py_DECREF(tmp);
388-
use_broken_old_ctypes_semantics = 1;
389-
}
390-
else {
391-
use_broken_old_ctypes_semantics = 0;
392-
}
393-
394373
if (_PyObject_LookupAttr(type, &_Py_ID(_pack_), &tmp) < 0) {
395374
return -1;
396375
}
@@ -454,7 +433,7 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
454433
if (!isStruct) {
455434
stgdict->flags |= TYPEFLAG_HASUNION;
456435
}
457-
if (basedict && !use_broken_old_ctypes_semantics) {
436+
if (basedict) {
458437
size = offset = basedict->size;
459438
align = basedict->align;
460439
union_size = 0;

0 commit comments

Comments
 (0)