From 63d1574cf8a5c76e63782d09066dd600f0d3c74d Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 9 Nov 2022 12:51:53 +0300 Subject: [PATCH 1/3] gh-99284: [ctypes] remove `_use_broken_old_ctypes_structure_semantics_` --- .../pycore_global_objects_fini_generated.h | 1 - Include/internal/pycore_global_strings.h | 1 - .../internal/pycore_runtime_init_generated.h | 1 - .../internal/pycore_unicodeobject_generated.h | 2 -- ...2-11-09-12-36-12.gh-issue-99284.9p4J2l.rst | 2 ++ Modules/_ctypes/stgdict.c | 23 +------------------ Tools/c-analyzer/cpython/globals-to-fix.tsv | 1 - 7 files changed, 3 insertions(+), 28 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2022-11-09-12-36-12.gh-issue-99284.9p4J2l.rst diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index f734e4b48a34ae..3d8d046bb4f478 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -763,7 +763,6 @@ _PyStaticObjects_CheckRefcnt(void) { _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 8588aaeb930004..50ce93fe3eb986 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -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) diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index 0dcb26d46f9cf6..aba572141c2db9 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -759,7 +759,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 026945f1e342a9..ceb08db0664b15 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 00000000000000..c558fe630619d2 --- /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_` hack from +:mod:`ctypes`. diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c index 975916dcd9685e..32adc72d048f9a 100644 --- a/Modules/_ctypes/stgdict.c +++ b/Modules/_ctypes/stgdict.c @@ -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; @@ -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; } @@ -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; diff --git a/Tools/c-analyzer/cpython/globals-to-fix.tsv b/Tools/c-analyzer/cpython/globals-to-fix.tsv index 56e499dcf98836..eedc40669331b1 100644 --- a/Tools/c-analyzer/cpython/globals-to-fix.tsv +++ b/Tools/c-analyzer/cpython/globals-to-fix.tsv @@ -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 - From 1388dd0a28046a15a7890f6d4082c87b98c65757 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Fri, 18 Nov 2022 20:49:24 +0300 Subject: [PATCH 2/3] Address review --- Doc/whatsnew/3.12.rst | 4 ++++ .../Library/2022-11-09-12-36-12.gh-issue-99284.9p4J2l.rst | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index 7ebfc5537c7a3d..eebf3b6341689f 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -850,3 +850,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/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 index c558fe630619d2..48576bd457aa0d 100644 --- 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 @@ -1,2 +1,2 @@ -Remove `_use_broken_old_ctypes_structure_semantics_` hack from -:mod:`ctypes`. +Remove ``_use_broken_old_ctypes_structure_semantics_`` +old untested and undocumented hack from :mod:`ctypes`. From 7962b117ead5ed9e015ec122da08055ceb24c58b Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Fri, 18 Nov 2022 21:17:54 +0300 Subject: [PATCH 3/3] Update globals-to-fix.tsv --- Tools/c-analyzer/cpython/globals-to-fix.tsv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/c-analyzer/cpython/globals-to-fix.tsv b/Tools/c-analyzer/cpython/globals-to-fix.tsv index 03745c41e66aa8..cc465134a9e065 100644 --- a/Tools/c-analyzer/cpython/globals-to-fix.tsv +++ b/Tools/c-analyzer/cpython/globals-to-fix.tsv @@ -688,4 +688,4 @@ Modules/readline.c - completed_input_string - Modules/rotatingtree.c - random_stream - Modules/rotatingtree.c - random_value - Modules/socketmodule.c - defaulttimeout - -Modules/syslogmodule.c - S_log_open - \ No newline at end of file +Modules/syslogmodule.c - S_log_open - pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy