PYTHON-5033 Use PyModule_Add on >= 3.13 (#2332)

This commit is contained in:
Jeffrey A. Clark 2025-05-08 17:14:26 -04:00 committed by GitHub
parent 98b030af94
commit 2655bb4d86
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3227,11 +3227,18 @@ _cbson_exec(PyObject *m)
INITERROR;
}
#if PY_VERSION_HEX >= 0x030D0000
if (PyModule_Add(m, "_C_API", c_api_object) < 0) {
Py_DECREF(m);
INITERROR;
}
# else
if (PyModule_AddObject(m, "_C_API", c_api_object) < 0) {
Py_DECREF(c_api_object);
Py_DECREF(m);
INITERROR;
}
#endif
return 0;
}