Patchwork [6,of,7] osutil: use PYMODULEINIT

login
register
mail settings
Submitter Jun Wu
Date May 9, 2017, 1:07 a.m.
Message ID <ad8cf58a8ba5bf96e602.1494292047@x1c>
Download mbox | patch
Permalink /patch/20536/
State Superseded
Headers show

Comments

Jun Wu - May 9, 2017, 1:07 a.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1494288978 25200
#      Mon May 08 17:16:18 2017 -0700
# Node ID ad8cf58a8ba5bf96e6020eb88560c283eb7463c6
# Parent  219c4e0d41d807078e3cc9663da11243e81625dd
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r ad8cf58a8ba5
osutil: use PYMODULEINIT

Patch

diff --git a/mercurial/osutil.c b/mercurial/osutil.c
--- a/mercurial/osutil.c
+++ b/mercurial/osutil.c
@@ -1302,27 +1302,7 @@  static PyMethodDef methods[] = {
 };
 
-#ifdef IS_PY3K
-static struct PyModuleDef osutil_module = {
-	PyModuleDef_HEAD_INIT,
-	"osutil",
-	osutil_doc,
-	-1,
-	methods
-};
+static int precheck(void) {
+	return PyType_Ready(&listdir_stat_type);
+}
 
-PyMODINIT_FUNC PyInit_osutil(void)
-{
-	if (PyType_Ready(&listdir_stat_type) < 0)
-		return NULL;
-
-	return PyModule_Create(&osutil_module);
-}
-#else
-PyMODINIT_FUNC initosutil(void)
-{
-	if (PyType_Ready(&listdir_stat_type) == -1)
-		return;
-
-	Py_InitModule3("osutil", methods, osutil_doc);
-}
-#endif
+PYMODULEINIT(osutil, methods, osutil_doc, 1, precheck, NULL);