Implement PEP 3121: new module initialization and finalization API.
diff --git a/Modules/_sre.c b/Modules/_sre.c
index 22aff76..ab8adda 100644
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -3387,7 +3387,19 @@
     {NULL, NULL}
 };
 
-PyMODINIT_FUNC init_sre(void)
+static struct PyModuleDef sremodule = {
+	PyModuleDef_HEAD_INIT,
+	"_" SRE_MODULE,
+	NULL,
+	-1,
+	_functions,
+	NULL,
+	NULL,
+	NULL,
+	NULL
+};
+
+PyMODINIT_FUNC PyInit__sre(void)
 {
     PyObject* m;
     PyObject* d;
@@ -3395,15 +3407,15 @@
 
     /* Initialize object types */
     if (PyType_Ready(&Pattern_Type) < 0)
-        return;
+        return NULL;
     if (PyType_Ready(&Match_Type) < 0)
-        return;
+        return NULL;
     if (PyType_Ready(&Scanner_Type) < 0)
-        return;
+        return NULL;
 
-    m = Py_InitModule("_" SRE_MODULE, _functions);
+    m = PyModule_Create(&sremodule);
     if (m == NULL)
-    	return;
+    	return NULL;
     d = PyModule_GetDict(m);
 
     x = PyLong_FromLong(SRE_MAGIC);
@@ -3423,6 +3435,7 @@
         PyDict_SetItemString(d, "copyright", x);
         Py_DECREF(x);
     }
+    return m;
 }
 
 #endif /* !defined(SRE_RECURSIVE) */