py3: add PY23() macro to switch string literal depending on python version
authorYuya Nishihara <yuya@tcha.org>
Sat, 03 Mar 2018 05:58:41 -0500
changeset 36618 9a639a33ad1f
parent 36617 5246f940a48e
child 36619 1f8c3fadbb8e
py3: add PY23() macro to switch string literal depending on python version I have no better idea to work around the bytes-unicode divergence of Py_BuildValue(). Maybe we can write a code transformer for C extensions? :)
mercurial/cext/util.h
--- a/mercurial/cext/util.h	Sat Mar 03 05:50:45 2018 -0500
+++ b/mercurial/cext/util.h	Sat Mar 03 05:58:41 2018 -0500
@@ -14,6 +14,13 @@
 #define IS_PY3K
 #endif
 
+/* helper to switch things like string literal depending on Python version */
+#ifdef IS_PY3K
+#define PY23(py2, py3) py3
+#else
+#define PY23(py2, py3) py2
+#endif
+
 /* clang-format off */
 typedef struct {
 	PyObject_HEAD