Patchwork [2,of,8] base85: add _version to help detect breaking binary changes

login
register
mail settings
Submitter Jun Wu
Date May 3, 2017, 12:19 a.m.
Message ID <28d82d6b0db973570d25.1493770799@x1c>
Download mbox | patch
Permalink /patch/20377/
State Deferred
Headers show

Comments

Jun Wu - May 3, 2017, 12:19 a.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1493167548 25200
#      Tue Apr 25 17:45:48 2017 -0700
# Node ID 28d82d6b0db973570d25d1082a9977ed1bb695de
# Parent  9073b1dfb58eb71c1005dad5267b6ee4f09790da
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 28d82d6b0db9
base85: add _version to help detect breaking binary changes

Patch

diff --git a/mercurial/base85.c b/mercurial/base85.c
--- a/mercurial/base85.c
+++ b/mercurial/base85.c
@@ -158,4 +158,8 @@  static PyMethodDef methods[] = {
 };
 
+/* Binary version. When breaking changes are made, bump this number and change
+ * __init__.py, so the module loader can notice and fallback to pure. */
+static const int _version = 1;
+
 #ifdef IS_PY3K
 static struct PyModuleDef base85_module = {
@@ -169,14 +173,18 @@  static struct PyModuleDef base85_module 
 PyMODINIT_FUNC PyInit_base85(void)
 {
+	PyObject *m;
 	b85prep();
 
-	return PyModule_Create(&base85_module);
+	m = PyModule_Create(&base85_module);
+	PyModule_AddIntConstant(m, "_version", _version);
 }
 #else
 PyMODINIT_FUNC initbase85(void)
 {
-	Py_InitModule3("base85", methods, base85_doc);
+	PyObject *m;
+	m = Py_InitModule3("base85", methods, base85_doc);
 
 	b85prep();
+	PyModule_AddIntConstant(m, "_version", _version);
 }
 #endif