summaryrefslogtreecommitdiffstats
path: root/Modules/binascii.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-06-11 05:26:20 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2008-06-11 05:26:20 (GMT)
commit1a21451b1d73b65af949193208372e86bf308411 (patch)
tree8e98d7be9e249b011ae9380479656e5284ec0234 /Modules/binascii.c
parentcdf94635d7e364f9ce1905bafa5b540f4d16147c (diff)
downloadcpython-1a21451b1d73b65af949193208372e86bf308411.zip
cpython-1a21451b1d73b65af949193208372e86bf308411.tar.gz
cpython-1a21451b1d73b65af949193208372e86bf308411.tar.bz2
Implement PEP 3121: new module initialization and finalization API.
Diffstat (limited to 'Modules/binascii.c')
-rw-r--r--Modules/binascii.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/Modules/binascii.c b/Modules/binascii.c
index 62b86a8..d3e8a51 100644
--- a/Modules/binascii.c
+++ b/Modules/binascii.c
@@ -1357,18 +1357,31 @@ static struct PyMethodDef binascii_module_methods[] = {
};
-/* Initialization function for the module (*must* be called initbinascii) */
+/* Initialization function for the module (*must* be called PyInit_binascii) */
PyDoc_STRVAR(doc_binascii, "Conversion between binary data and ASCII");
+
+static struct PyModuleDef binasciimodule = {
+ PyModuleDef_HEAD_INIT,
+ "binascii",
+ doc_binascii,
+ -1,
+ binascii_module_methods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
PyMODINIT_FUNC
-initbinascii(void)
+PyInit_binascii(void)
{
PyObject *m, *d;
/* Create the module and add the functions */
- m = Py_InitModule3("binascii", binascii_module_methods, doc_binascii);
+ m = PyModule_Create(&binasciimodule);
if (m == NULL)
- return;
+ return NULL;
d = PyModule_GetDict(m);
@@ -1376,4 +1389,9 @@ initbinascii(void)
PyDict_SetItemString(d, "Error", Error);
Incomplete = PyErr_NewException("binascii.Incomplete", NULL, NULL);
PyDict_SetItemString(d, "Incomplete", Incomplete);
+ if (PyErr_Occurred()) {
+ Py_DECREF(m);
+ m = NULL;
+ }
+ return m;
}