[PATCH 6 of 7] osutil: use PYMODULEINIT
Jun Wu
quark at fb.com
Mon May 8 21:07:27 EDT 2017
# HG changeset patch
# User Jun Wu <quark at 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
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);
More information about the Mercurial-devel
mailing list