Patchwork [3,of,6,v2] parsers: fix typing issue when constructing Python integer object

login
register
mail settings
Submitter Henrik Stuart
Date Sept. 9, 2014, 5:51 p.m.
Message ID <620d7f5d8ff74d46159e.1410285099@yggdrasil>
Download mbox | patch
Permalink /patch/5741/
State Accepted
Headers show

Comments

Henrik Stuart - Sept. 9, 2014, 5:51 p.m.
# HG changeset patch
# User Henrik Stuart <hg@hstuart.dk>
# Date 1410199995 -7200
#      Mon Sep 08 20:13:15 2014 +0200
# Node ID 620d7f5d8ff74d46159e8fb83ebf3c9e401216b7
# Parent  f8504d79534d8753abccaa0f69f1100f8e2a3d4d
parsers: fix typing issue when constructing Python integer object

The passed variable is a Py_ssize_t, not a long, and consequently should use
PyInt_FromSsize_t rather than PyInt-FromLong. Fixed based on warning from
Microsoft Visual C++ 2008.

Patch

diff -r f8504d79534d -r 620d7f5d8ff7 mercurial/parsers.c
--- a/mercurial/parsers.c	Mon Sep 08 20:06:52 2014 +0200
+++ b/mercurial/parsers.c	Mon Sep 08 20:13:15 2014 +0200
@@ -881,7 +881,7 @@ 
 
 		if (nothead[i])
 			continue;
-		head = PyInt_FromLong(i);
+		head = PyInt_FromSsize_t(i);
 		if (head == NULL || PyList_Append(heads, head) == -1) {
 			Py_XDECREF(head);
 			goto bail;