cext: remove Python 2 module initializer functions
authorGregory Szorc <gregory.szorc@gmail.com>
Sun, 20 Feb 2022 15:40:39 -0700
changeset 48810 ed03fffaac30
parent 48809 1d5fd9def5ac
child 48811 92c430e7e37a
cext: remove Python 2 module initializer functions We no longer need these since we dropped support for Python 2. Differential Revision: https://phab.mercurial-scm.org/D12221
mercurial/cext/base85.c
mercurial/cext/bdiff.c
mercurial/cext/mpatch.c
mercurial/cext/osutil.c
mercurial/cext/parsers.c
--- a/mercurial/cext/base85.c	Mon Feb 21 19:51:23 2022 +0000
+++ b/mercurial/cext/base85.c	Sun Feb 20 15:40:39 2022 -0700
@@ -177,7 +177,6 @@
 
 static const int version = 1;
 
-#ifdef IS_PY3K
 static struct PyModuleDef base85_module = {
     PyModuleDef_HEAD_INIT, "base85", base85_doc, -1, methods,
 };
@@ -191,13 +190,3 @@
 	PyModule_AddIntConstant(m, "version", version);
 	return m;
 }
-#else
-PyMODINIT_FUNC initbase85(void)
-{
-	PyObject *m;
-	m = Py_InitModule3("base85", methods, base85_doc);
-
-	b85prep();
-	PyModule_AddIntConstant(m, "version", version);
-}
-#endif
--- a/mercurial/cext/bdiff.c	Mon Feb 21 19:51:23 2022 +0000
+++ b/mercurial/cext/bdiff.c	Sun Feb 20 15:40:39 2022 -0700
@@ -337,7 +337,6 @@
 
 static const int version = 3;
 
-#ifdef IS_PY3K
 static struct PyModuleDef bdiff_module = {
     PyModuleDef_HEAD_INIT, "bdiff", mdiff_doc, -1, methods,
 };
@@ -349,11 +348,3 @@
 	PyModule_AddIntConstant(m, "version", version);
 	return m;
 }
-#else
-PyMODINIT_FUNC initbdiff(void)
-{
-	PyObject *m;
-	m = Py_InitModule3("bdiff", methods, mdiff_doc);
-	PyModule_AddIntConstant(m, "version", version);
-}
-#endif
--- a/mercurial/cext/mpatch.c	Mon Feb 21 19:51:23 2022 +0000
+++ b/mercurial/cext/mpatch.c	Sun Feb 20 15:40:39 2022 -0700
@@ -182,7 +182,6 @@
 
 static const int version = 1;
 
-#ifdef IS_PY3K
 static struct PyModuleDef mpatch_module = {
     PyModuleDef_HEAD_INIT, "mpatch", mpatch_doc, -1, methods,
 };
@@ -203,13 +202,3 @@
 
 	return m;
 }
-#else
-PyMODINIT_FUNC initmpatch(void)
-{
-	PyObject *m;
-	m = Py_InitModule3("mpatch", methods, mpatch_doc);
-	mpatch_Error =
-	    PyErr_NewException("mercurial.cext.mpatch.mpatchError", NULL, NULL);
-	PyModule_AddIntConstant(m, "version", version);
-}
-#endif
--- a/mercurial/cext/osutil.c	Mon Feb 21 19:51:23 2022 +0000
+++ b/mercurial/cext/osutil.c	Sun Feb 20 15:40:39 2022 -0700
@@ -1387,7 +1387,6 @@
 
 static const int version = 4;
 
-#ifdef IS_PY3K
 static struct PyModuleDef osutil_module = {
 	PyModuleDef_HEAD_INIT,
 	"osutil",
@@ -1406,14 +1405,3 @@
 	PyModule_AddIntConstant(m, "version", version);
 	return m;
 }
-#else
-PyMODINIT_FUNC initosutil(void)
-{
-	PyObject *m;
-	if (PyType_Ready(&listdir_stat_type) == -1)
-		return;
-
-	m = Py_InitModule3("osutil", methods, osutil_doc);
-	PyModule_AddIntConstant(m, "version", version);
-}
-#endif
--- a/mercurial/cext/parsers.c	Mon Feb 21 19:51:23 2022 +0000
+++ b/mercurial/cext/parsers.c	Sun Feb 20 15:40:39 2022 -0700
@@ -1307,7 +1307,6 @@
 	return 0;
 }
 
-#ifdef IS_PY3K
 static struct PyModuleDef parsers_module = {PyModuleDef_HEAD_INIT, "parsers",
                                             parsers_doc, -1, methods};
 
@@ -1321,15 +1320,3 @@
 	module_init(mod);
 	return mod;
 }
-#else
-PyMODINIT_FUNC initparsers(void)
-{
-	PyObject *mod;
-
-	if (check_python_version() == -1) {
-		return;
-	}
-	mod = Py_InitModule3("parsers", methods, parsers_doc);
-	module_init(mod);
-}
-#endif