https://github.com/python/cpython/commit/875337080e77ebe563341e7852c953d2bc81b58e
commit: 875337080e77ebe563341e7852c953d2bc81b58e
branch: main
author: Peter Bierma <[email protected]>
committer: ZeroIntensity <[email protected]>
date: 2026-10-20T18:40:27-04:00
summary:

gh-78327: Fix buildbot failures on Windows Clang (GH-159936)

files:
M Modules/_ctypes/_ctypes.c

diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index ae49cbf3e57da7..dc146e41109f80 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -3221,16 +3221,17 @@ static PyMethodDef PyCData_methods[] = {
  * PyObject_HashNotImplemented() makes type_ready() set __hash__ to None.
  *
  * Unfortunately, on Windows, PyObject_HashNotImplemented is imported from
- * the Python DLL, and MSVC resolves the address of an imported function in
- * a static initializer to a local thunk that can't be recognized. So, we
- * initialize the slots at runtime to load the real address from the import 
table.
+ * the Python DLL. MSVC resolves imported functions in static initializers to
+ * local thunks, and Clang does the same even for local aggregate initializers.
+ * Assign the hash slot explicitly at runtime to load the real address from
+ * the import table.
  */
 static PyObject *
 PyCData_create_type(PyObject *mod)
 {
     PyType_Slot slots[] = {
         {Py_tp_dealloc, PyCData_dealloc},
-        {Py_tp_hash, PyObject_HashNotImplemented},
+        {Py_tp_hash, NULL},
         {Py_tp_doc, PyDoc_STR("The common base class of all ctypes "
                               "data types.")},
         {Py_tp_traverse, PyCData_traverse},
@@ -3240,6 +3241,7 @@ PyCData_create_type(PyObject *mod)
         {Py_bf_getbuffer, PyCData_NewGetBuffer},
         {0, NULL},
     };
+    slots[1].pfunc = PyObject_HashNotImplemented;
     PyType_Spec spec = {
         .name = "_ctypes._CData",
         .basicsize = sizeof(CDataObject),

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to