Skip to content

Commit 8f76168

Browse files
committed
Fix c extension on python 3.12
Workaround for [1]. [1] python/cpython#103940 Signed-off-by: Sean Anderson <[email protected]>
1 parent 2a22a9f commit 8f76168

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

atomic.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ static int TYPE_ADD(PyObject *m)
165165
return ret;
166166
}
167167

168+
TYPE.tp_base = &BufferType;
169+
if (PyType_Ready(&TYPE))
170+
return -1;
171+
168172
if (PyType_AddSizeConstant(&TYPE, "size", sizeof(PTYPE)))
169173
return -1;
170174

@@ -192,7 +196,6 @@ static int TYPE_ADD(PyObject *m)
192196
#endif
193197
#endif
194198

195-
TYPE.tp_base = &BufferType;
196199
Py_INCREF(&BufferType);
197200
ret = PyModule_AddType(m, &TYPE);
198201
Py_DECREF(&BufferType);

lock.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,17 @@ int LockType_Add(PyObject *m)
217217
return -1;
218218
}
219219

220+
LockType.tp_base = &BufferType;
221+
if (PyType_Ready(&LockType))
222+
return -1;
223+
220224
if (PyType_AddSizeConstant(&LockType, "size", sizeof(pthread_mutex_t)))
221225
return -1;
222226

223227
if (PyType_AddSizeConstant(&LockType, "align",
224228
alignof(pthread_mutex_t)))
225229
return -1;
226230

227-
LockType.tp_base = &BufferType;
228231
Py_INCREF(&BufferType);
229232
err = PyModule_AddType(m, &LockType);
230233
Py_DECREF(&BufferType);

0 commit comments

Comments
 (0)