Implement PEP 3121: new module initialization and finalization API.
diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c
index 77b238d..4cdd98d 100644
--- a/Modules/_randommodule.c
+++ b/Modules/_randommodule.c
@@ -496,16 +496,30 @@
 PyDoc_STRVAR(module_doc,
 "Module implements the Mersenne Twister random number generator.");
 
+
+static struct PyModuleDef _randommodule = {
+	PyModuleDef_HEAD_INIT,
+	"_random",
+	module_doc,
+	-1,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL
+};
+
 PyMODINIT_FUNC
-init_random(void)
+PyInit__random(void)
 {
 	PyObject *m;
 
 	if (PyType_Ready(&Random_Type) < 0)
-		return;
-	m = Py_InitModule3("_random", NULL, module_doc);
+		return NULL;
+	m = PyModule_Create(&_randommodule);
 	if (m == NULL)
-		return;
+		return NULL;
 	Py_INCREF(&Random_Type);
 	PyModule_AddObject(m, "Random", (PyObject *)&Random_Type);
+	return m;
 }