changeset 36618:9a639a33ad1f

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? :)
author Yuya Nishihara <yuya@tcha.org>
date Sat, 03 Mar 2018 05:58:41 -0500
parents 5246f940a48e
children 1f8c3fadbb8e
files mercurial/cext/util.h
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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