Skip to content

Commit

Permalink
pythongh-99284: [ctypes] remove `_use_broken_old_ctypes_structure_sem…
Browse files Browse the repository at this point in the history
…antics_`
  • Loading branch information
sobolevn committed Nov 9, 2022
1 parent 0124b5d commit 63d1574
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 28 deletions.
1 change: 0 additions & 1 deletion Include/internal/pycore_global_objects_fini_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Include/internal/pycore_global_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ struct _Py_global_strings {
STRUCT_FOR_ID(_swappedbytes_)
STRUCT_FOR_ID(_type_)
STRUCT_FOR_ID(_uninitialized_submodules)
STRUCT_FOR_ID(_use_broken_old_ctypes_structure_semantics_)
STRUCT_FOR_ID(_warn_unawaited_coroutine)
STRUCT_FOR_ID(_xoptions)
STRUCT_FOR_ID(a)
Expand Down
1 change: 0 additions & 1 deletion Include/internal/pycore_runtime_init_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Include/internal/pycore_unicodeobject_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Remove `_use_broken_old_ctypes_structure_semantics_` hack from
:mod:`ctypes`.
23 changes: 1 addition & 22 deletions Modules/_ctypes/stgdict.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,14 +357,6 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
int big_endian;
int arrays_seen = 0;

/* HACK Alert: I cannot be bothered to fix ctypes.com, so there has to
be a way to use the old, broken semantics: _fields_ are not extended
but replaced in subclasses.
XXX Remove this in ctypes 1.0!
*/
int use_broken_old_ctypes_semantics;

if (fields == NULL)
return 0;

Expand All @@ -379,19 +371,6 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
big_endian = PY_BIG_ENDIAN;
}

if (_PyObject_LookupAttr(type,
&_Py_ID(_use_broken_old_ctypes_structure_semantics_), &tmp) < 0)
{
return -1;
}
if (tmp) {
Py_DECREF(tmp);
use_broken_old_ctypes_semantics = 1;
}
else {
use_broken_old_ctypes_semantics = 0;
}

if (_PyObject_LookupAttr(type, &_Py_ID(_pack_), &tmp) < 0) {
return -1;
}
Expand Down Expand Up @@ -452,7 +431,7 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
if (!isStruct) {
stgdict->flags |= TYPEFLAG_HASUNION;
}
if (basedict && !use_broken_old_ctypes_semantics) {
if (basedict) {
size = offset = basedict->size;
align = basedict->align;
union_size = 0;
Expand Down
1 change: 0 additions & 1 deletion Tools/c-analyzer/cpython/globals-to-fix.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,6 @@ Modules/_ctypes/callproc.c unpickle PyId___setstate__ -
Modules/_ctypes/stgdict.c MakeAnonFields PyId__anonymous_ -
Modules/_ctypes/stgdict.c PyCStructUnionType_update_stgdict PyId__pack_ -
Modules/_ctypes/stgdict.c PyCStructUnionType_update_stgdict PyId__swappedbytes_ -
Modules/_ctypes/stgdict.c PyCStructUnionType_update_stgdict PyId__use_broken_old_ctypes_structure_semantics_ -
Modules/_cursesmodule.c _curses_getwin PyId_read -
Modules/_cursesmodule.c _curses_window_putwin PyId_write -
Modules/_cursesmodule.c update_lines_cols PyId_COLS -
Expand Down

0 comments on commit 63d1574

Please sign in to comment.