Patchwork [01,of,11,py3] parsers: move PyInt aliasing out of util.h

login
register
mail settings
Submitter Augie Fackler
Date Oct. 9, 2016, 2:16 p.m.
Message ID <9b6ff0f940ed2ee33516.1476022603@augie-macbookair2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/16997/
State Accepted
Headers show

Comments

Augie Fackler - Oct. 9, 2016, 2:16 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1476013853 -7200
#      Sun Oct 09 13:50:53 2016 +0200
# Node ID 9b6ff0f940ed2ee33516aac22d5c69914400af7a
# Parent  a989fa78dafa228d09c12c48e9e2d85ed7a9beb7
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.
Augie Fackler - Oct. 9, 2016, 3:08 p.m.
> On Oct 9, 2016, at 16:16, Augie Fackler <raf@durin42.com> wrote:
> 
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1476013853 -7200
> #      Sun Oct 09 13:50:53 2016 +0200
> # Node ID 9b6ff0f940ed2ee33516aac22d5c69914400af7a
> # Parent  a989fa78dafa228d09c12c48e9e2d85ed7a9beb7
> parsers: move PyInt aliasing out of util.h

Ugh, ignore this first patch (but please review the rest of the series). I copied the wrong hash for email.

Patch

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -15,6 +15,15 @@ 
 #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] = {
diff --git a/mercurial/util.h b/mercurial/util.h
--- a/mercurial/util.h
+++ b/mercurial/util.h
@@ -11,16 +11,8 @@ 
 #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