add a replacement API for PyCObject, PyCapsule #5630

All stdlib modules with C-APIs now use this.

Patch by Larry Hastings
This commit is contained in:
Benjamin Peterson 2009-05-05 22:31:58 +00:00
parent c679fd8efc
commit b173f7853e
37 changed files with 943 additions and 149 deletions

View file

@ -4146,6 +4146,14 @@ PySocketModule_APIObject PySocketModuleAPI =
NULL
};
PySocketModule_APIObject *
PySocketModule_ImportModuleAndAPI(void)
{
void *api;
api = PyCapsule_Import(PySocket_CAPSULE_NAME, 1);;
return (PySocketModule_APIObject *)api;
}
/* Initialize the _socket module.
@ -4231,7 +4239,7 @@ PyInit__socket(void)
/* Export C API */
if (PyModule_AddObject(m, PySocket_CAPI_NAME,
PyCObject_FromVoidPtr((void *)&PySocketModuleAPI, NULL)
PyCapsule_New(&PySocketModuleAPI, PySocket_CAPSULE_NAME, NULL)
) != 0)
return NULL;