Patchwork [3,of,3] parsers: move PyInt aliasing out of util.h

login
register
mail settings
Submitter Gregory Szorc
Date Oct. 9, 2016, 11:57 a.m.
Message ID <8b64753501ab0cf99548.1476014244@gps-mbp.local>
Download mbox | patch
Permalink /patch/16985/
State Accepted
Headers show

Comments

Gregory Szorc - Oct. 9, 2016, 11:57 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1476013853 -7200
#      Sun Oct 09 13:50:53 2016 +0200
# Node ID 8b64753501ab0cf9954824ee32997d53205a7cf4
# Parent  6bdfe20ea811ac7e873072763d43f29c23edc409
parsers: move PyInt aliasing out of util.h

The PyInt aliasing is only used by parsers.c. Since we don't want to
encourage the use of PyInt parsing, move the aliasing to parsers.c.
timeless - Oct. 21, 2016, 1:23 p.m.
Gregory Szorc wrote:
> + * 3 to compile. We should remove this once Python 3 support is fully
> + * supported and proper types are used in the extensions themselves. */


Previously the comment was in a reusable header. It is no longer, so I
suspect the portion about extensions is no longer applicable.

Patch

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -14,8 +14,17 @@ 
 
 #include "util.h"
 #include "bitmanipulation.h"
 
+#ifdef IS_PY3K
+/* The mapping of Python types is meant to be temporary to get Python
+ * 3 to compile. We should remove this once Python 3 support is fully
+ * supported and proper types are used in the extensions themselves. */
+#define PyInt_Type PyLong_Type
+#define PyInt_FromLong PyLong_FromLong
+#define PyInt_AsLong PyLong_AsLong
+#endif
+
 static char *versionerrortext = "Python minor version mismatch";
 
 static int8_t hextable[256] = {
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
diff --git a/mercurial/util.h b/mercurial/util.h
--- a/mercurial/util.h
+++ b/mercurial/util.h
@@ -10,18 +10,10 @@ 
 
 #include "compat.h"
 
 #if PY_MAJOR_VERSION >= 3
-
 #define IS_PY3K
-/* The mapping of Python types is meant to be temporary to get Python
- * 3 to compile. We should remove this once Python 3 support is fully
- * supported and proper types are used in the extensions themselves. */
-#define PyInt_Type PyLong_Type
-#define PyInt_FromLong PyLong_FromLong
-#define PyInt_AsLong PyLong_AsLong
-
-#endif /* PY_MAJOR_VERSION */
+#endif
 
 typedef struct {
 	PyObject_HEAD
 	char state;