diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2022-11-19 06:25:32 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-19 06:25:32 (GMT) |
commit | a3360facbaa8886f1e6f8a80057230371fee675b (patch) | |
tree | 4d4481f288dbe57348e632165f3dcff1295f644b | |
parent | 27d8dc2c9d3de886a884f79f0621d4586c0e0f7a (diff) | |
download | cpython-a3360facbaa8886f1e6f8a80057230371fee675b.zip cpython-a3360facbaa8886f1e6f8a80057230371fee675b.tar.gz cpython-a3360facbaa8886f1e6f8a80057230371fee675b.tar.bz2 |
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.
-rw-r--r-- | Doc/whatsnew/3.12.rst | 4 | ||||
-rw-r--r-- | Include/internal/pycore_global_objects_fini_generated.h | 1 | ||||
-rw-r--r-- | Include/internal/pycore_global_strings.h | 1 | ||||
-rw-r--r-- | Include/internal/pycore_runtime_init_generated.h | 1 | ||||
-rw-r--r-- | Include/internal/pycore_unicodeobject_generated.h | 2 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2022-11-09-12-36-12.gh-issue-99284.9p4J2l.rst | 2 | ||||
-rw-r--r-- | Modules/_ctypes/stgdict.c | 23 |
7 files changed, 7 insertions, 27 deletions
diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index bb08e44..f8786c1 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -873,3 +873,7 @@ Removed * Remove the ``PyUnicode_InternImmortal()`` function and the ``SSTATE_INTERNED_IMMORTAL`` macro. (Contributed by Victor Stinner in :gh:`85858`.) + +* Remove ``_use_broken_old_ctypes_structure_semantics_`` flag + from :mod:`ctypes` module. + (Contributed by Nikita Sobolev in :gh:`99285`.) diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index 5fd08f2..381f166 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -765,7 +765,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_swappedbytes_)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_type_)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_uninitialized_submodules)); - _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_use_broken_old_ctypes_structure_semantics_)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_warn_unawaited_coroutine)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(_xoptions)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(a)); diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index 5bfd4be..b2b0dc6 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -251,7 +251,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) diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index 7228cb5..859e676 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -757,7 +757,6 @@ extern "C" { INIT_ID(_swappedbytes_), \ INIT_ID(_type_), \ INIT_ID(_uninitialized_submodules), \ - INIT_ID(_use_broken_old_ctypes_structure_semantics_), \ INIT_ID(_warn_unawaited_coroutine), \ INIT_ID(_xoptions), \ INIT_ID(a), \ diff --git a/Include/internal/pycore_unicodeobject_generated.h b/Include/internal/pycore_unicodeobject_generated.h index 208a1e1..abff03f 100644 --- a/Include/internal/pycore_unicodeobject_generated.h +++ b/Include/internal/pycore_unicodeobject_generated.h @@ -408,8 +408,6 @@ _PyUnicode_InitStaticStrings(void) { PyUnicode_InternInPlace(&string); string = &_Py_ID(_uninitialized_submodules); PyUnicode_InternInPlace(&string); - string = &_Py_ID(_use_broken_old_ctypes_structure_semantics_); - PyUnicode_InternInPlace(&string); string = &_Py_ID(_warn_unawaited_coroutine); PyUnicode_InternInPlace(&string); string = &_Py_ID(_xoptions); diff --git a/Misc/NEWS.d/next/Library/2022-11-09-12-36-12.gh-issue-99284.9p4J2l.rst b/Misc/NEWS.d/next/Library/2022-11-09-12-36-12.gh-issue-99284.9p4J2l.rst new file mode 100644 index 0000000..48576bd --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-11-09-12-36-12.gh-issue-99284.9p4J2l.rst @@ -0,0 +1,2 @@ +Remove ``_use_broken_old_ctypes_structure_semantics_`` +old untested and undocumented hack from :mod:`ctypes`. diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c index 9f031b0..099331c 100644 --- a/Modules/_ctypes/stgdict.c +++ b/Modules/_ctypes/stgdict.c @@ -356,14 +356,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; @@ -378,19 +370,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; } @@ -454,7 +433,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; |