Skip to content

Commit 8753370

Browse files
gh-78327: Fix buildbot failures on Windows Clang (GH-159936)
1 parent 80040b6 commit 8753370

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎Modules/_ctypes/_ctypes.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3221,16 +3221,17 @@ static PyMethodDef PyCData_methods[] = {
32213221
* PyObject_HashNotImplemented() makes type_ready() set __hash__ to None.
32223222
*
32233223
* Unfortunately, on Windows, PyObject_HashNotImplemented is imported from
3224-
* the Python DLL, and MSVC resolves the address of an imported function in
3225-
* a static initializer to a local thunk that can't be recognized. So, we
3226-
* initialize the slots at runtime to load the real address from the import table.
3224+
* the Python DLL. MSVC resolves imported functions in static initializers to
3225+
* local thunks, and Clang does the same even for local aggregate initializers.
3226+
* Assign the hash slot explicitly at runtime to load the real address from
3227+
* the import table.
32273228
*/
32283229
static PyObject *
32293230
PyCData_create_type(PyObject *mod)
32303231
{
32313232
PyType_Slot slots[] = {
32323233
{Py_tp_dealloc, PyCData_dealloc},
3233-
{Py_tp_hash, PyObject_HashNotImplemented},
3234+
{Py_tp_hash, NULL},
32343235
{Py_tp_doc, PyDoc_STR("The common base class of all ctypes "
32353236
"data types.")},
32363237
{Py_tp_traverse, PyCData_traverse},
@@ -3240,6 +3241,7 @@ PyCData_create_type(PyObject *mod)
32403241
{Py_bf_getbuffer, PyCData_NewGetBuffer},
32413242
{0, NULL},
32423243
};
3244+
slots[1].pfunc = PyObject_HashNotImplemented;
32433245
PyType_Spec spec = {
32443246
.name = "_ctypes._CData",
32453247
.basicsize = sizeof(CDataObject),

0 commit comments

Comments
 (0)