Patchwork [2,of,7,V2] base85: use PYMODULEINIT

login
register
mail settings
Submitter Jun Wu
Date May 13, 2017, 6:55 p.m.
Message ID <407cb540b3a59ec291f2.1494701724@x1c>
Download mbox | patch
Permalink /patch/20598/
State Superseded
Headers show

Comments

Jun Wu - May 13, 2017, 6:55 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1494289632 25200
#      Mon May 08 17:27:12 2017 -0700
# Node ID 407cb540b3a59ec291f2166d1592af78d992fbfb
# Parent  55ae1324c950e76270ccb0f68c098513bc36fc91
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 407cb540b3a5
base85: use PYMODULEINIT

Patch

diff --git a/mercurial/base85.c b/mercurial/base85.c
--- a/mercurial/base85.c
+++ b/mercurial/base85.c
@@ -19,5 +19,5 @@  static const char b85chars[] = "01234567
 static char b85dec[256];
 
-static void b85prep(void)
+static int b85prep(void)
 {
 	unsigned i;
@@ -26,4 +26,6 @@  static void b85prep(void)
 	for (i = 0; i < sizeof(b85chars); i++)
 		b85dec[(int)(b85chars[i])] = i + 1;
+
+	return 0;
 }
 
@@ -158,25 +160,3 @@  static PyMethodDef methods[] = {
 };
 
-#ifdef IS_PY3K
-static struct PyModuleDef base85_module = {
-	PyModuleDef_HEAD_INIT,
-	"base85",
-	base85_doc,
-	-1,
-	methods
-};
-
-PyMODINIT_FUNC PyInit_base85(void)
-{
-	b85prep();
-
-	return PyModule_Create(&base85_module);
-}
-#else
-PyMODINIT_FUNC initbase85(void)
-{
-	Py_InitModule3("base85", methods, base85_doc);
-
-	b85prep();
-}
-#endif
+PYMODULEINIT(base85, methods, base85_doc, 1, b85prep(), SKIP);