Patchwork [2,of,2,stable] parsers: replace Py_BuildValue 'n' with 'k' for Python 2.4 compatibility

login
register
mail settings
Submitter Mads Kiilerich
Date Oct. 20, 2014, 2:56 a.m.
Message ID <7fba8c8c403bb9ff9e4e.1413773810@localhost.localdomain>
Download mbox | patch
Permalink /patch/6415/
State Accepted
Headers show

Comments

Mads Kiilerich - Oct. 20, 2014, 2:56 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1413773789 -7200
#      Mon Oct 20 04:56:29 2014 +0200
# Branch stable
# Node ID 7fba8c8c403bb9ff9e4e8addabe2413c3bdb00d8
# Parent  2ee3d9d0bc7be9b67f5f5f05db6faa2a9d927e2a
parsers: replace Py_BuildValue 'n' with 'k' for Python 2.4 compatibility

'n' was introduced in Mercurial in 2b5940f64750 and in Python in 2.5.

Not a good solution, but good is not an option when we have to support Python
2.4.

This fixes test-glog.t failure with Python 2.4.
Pierre-Yves David - Oct. 23, 2014, 12:18 a.m.
On 10/19/2014 07:56 PM, Mads Kiilerich wrote:
> parsers: replace Py_BuildValue 'n' with 'k' for Python 2.4 compatibility
>
> 'n' was introduced in Mercurial in 2b5940f64750 and in Python in 2.5.
>
> Not a good solution, but good is not an option when we have to support Python
> 2.4.

Can you be a bit mroe specific about what 'n and 'k mean here. And 
behavior change this change introduce?

Patch

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -873,12 +873,12 @@  static PyObject *list_copy(PyObject *lis
 	return newlist;
 }
 
-static int check_filter(PyObject *filter, Py_ssize_t arg) {
+static int check_filter(PyObject *filter, unsigned long arg) {
 	if (filter) {
 		PyObject *arglist, *result;
 		int isfiltered;
 
-		arglist = Py_BuildValue("(n)", arg);
+		arglist = Py_BuildValue("(k)", arg);
 		if (!arglist) {
 			return -1;
 		}