Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ctypes] Do we still need _use_broken_old_ctypes_structure_semantics_? #99284

Closed
sobolevn opened this issue Nov 9, 2022 · 1 comment
Closed
Labels
topic-ctypes type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

sobolevn commented Nov 9, 2022

While working on #99283 I've noticed this piece of code:

/* 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!

if (_PyObject_LookupAttr(type,
&_Py_ID(_use_broken_old_ctypes_structure_semantics_), &tmp) < 0)

I've never seen this before, so I went and searched for this on the internet: https://cs.github.com/?scopeName=All+repos&scope=&q=_use_broken_old_ctypes_structure_semantics_

Looks like not a single GitHub project uses it.

Where is that used inside?

» ag _use_broken_old_ctypes_structure_semantics_
Tools/c-analyzer/cpython/globals-to-fix.tsv
761:Modules/_ctypes/stgdict.c   PyCStructUnionType_update_stgdict       PyId__use_broken_old_ctypes_structure_semantics_      -

Include/internal/pycore_global_strings.h
253:        STRUCT_FOR_ID(_use_broken_old_ctypes_structure_semantics_)

Include/internal/pycore_runtime_init_generated.h
762:                INIT_ID(_use_broken_old_ctypes_structure_semantics_), \
1879:    string = &_Py_ID(_use_broken_old_ctypes_structure_semantics_);
5734:    if (Py_REFCNT((PyObject *)&_Py_ID(_use_broken_old_ctypes_structure_semantics_)) < _PyObject_IMMORTAL_REFCNT) {
5735:        _PyObject_Dump((PyObject *)&_Py_ID(_use_broken_old_ctypes_structure_semantics_));

Modules/_ctypes/stgdict.c
383:                &_Py_ID(_use_broken_old_ctypes_structure_semantics_), &tmp) < 0)

Basically in only one place (and generate code).
No docs, no tests.
No issues: https://github.com/python/cpython/issues?q=is%3Aissue+is%3Aopen+use_broken_old_ctypes_structure_semantics

And it feels like a python2 era thing.
I think it is time to remove it.

PR is on its way, so we can discuss the changes in more details.
CC @pitrou as the original author.

@sobolevn sobolevn added type-bug An unexpected behavior, bug, or error topic-ctypes labels Nov 9, 2022
sobolevn added a commit to sobolevn/cpython that referenced this issue Nov 9, 2022
gpshead pushed a commit that referenced this issue Nov 19, 2022
…s_` (GH-99285)

It was untested and undocumented. No code has been found in the wild that ever used it.
@vstinner
Copy link
Member

Fixed by a3360fa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-ctypes type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants