Skip to content

Commit fabc59a

Browse files
Replace Py_TYPE(obj)=type with Py_SET_TYPE()
Since Py_TYPE() was changed to an inline static function in PEP670, `Py_TYPE(obj) = new_type` must be replaced with the new function `Py_SET_TYPE(obj, new_type)`, available since Python 3.9. For backward compatibility, this macro can be used: ````c++ #if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_TYPE) static inline void _Py_SET_TYPE(PyObject *ob, PyTypeObject *type) { ob->ob_type = type; } #define Py_SET_TYPE(ob, type) _Py_SET_TYPE((PyObject*)(ob), type) #endif ```` See python/cpython#83754
1 parent b505f9b commit fabc59a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

bluetooth/linux/bluez/btmodule.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -3038,8 +3038,8 @@ static struct PyModuleDef moduledef = {
30383038
PyMODINIT_FUNC
30393039
PyInit__bluetooth(void)
30403040
{
3041-
Py_TYPE(&sock_type) = &PyType_Type;
3042-
Py_TYPE(&sdp_session_type) = &PyType_Type;
3041+
Py_SET_TYPE(&sock_type, &PyType_Type);
3042+
Py_SET_TYPE(&sdp_session_type, &PyType_Type);
30433043
PyObject *m = PyModule_Create(&moduledef);
30443044
if (m == NULL)
30453045
INITERROR;

0 commit comments

Comments
 (0)