add a replacement API for PyCObject, PyCapsule #5630
All stdlib modules with C-APIs now use this.
Patch by Larry Hastings
diff --git a/Modules/datetimemodule.c b/Modules/datetimemodule.c
index 0c6e664..8ba3474 100644
--- a/Modules/datetimemodule.c
+++ b/Modules/datetimemodule.c
@@ -4792,11 +4792,10 @@
Py_INCREF(&PyDateTime_TZInfoType);
PyModule_AddObject(m, "tzinfo", (PyObject *) &PyDateTime_TZInfoType);
- x = PyCObject_FromVoidPtrAndDesc(&CAPI, (void*) DATETIME_API_MAGIC,
- NULL);
- if (x == NULL)
- return NULL;
- PyModule_AddObject(m, "datetime_CAPI", x);
+ x = PyCapsule_New(&CAPI, PyDateTime_CAPSULE_NAME, NULL);
+ if (x == NULL)
+ return NULL;
+ PyModule_AddObject(m, "datetime_CAPI", x);
/* A 4-year cycle has an extra leap day over what we'd get from
* pasting together 4 single years.