[PATCH 1 of 3] osutil: use PyLongObject in recvfds

Gregory Szorc gregory.szorc at gmail.com
Sun Oct 9 11:57:22 UTC 2016


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1476013278 -7200
#      Sun Oct 09 13:41:18 2016 +0200
# Node ID 0cc68ebd34108cc609328379b46522b81f840851
# Parent  ad527a4c62ad35b84c4ad25d080ee427528966fa
osutil: use PyLongObject in recvfds

PyIntObject doesn't exist in Python 3. While PyIntObject is preferred
on Python 2 because it is a fixed capacity and faster, the difference
between PyIntObject and PyLongObject for scenarios where performance
isn't critical or the caller isn't performing type checking shouldn't
be relevant.

So change recvfds to return a list of longs instead of ints on Python
2.

diff --git a/mercurial/osutil.c b/mercurial/osutil.c
--- a/mercurial/osutil.c
+++ b/mercurial/osutil.c
@@ -705,9 +705,9 @@ static PyObject *recvfds(PyObject *self,
 	rfdslist = PyList_New(rfdscount);
 	if (!rfdslist)
 		goto bail;
 	for (i = 0; i < rfdscount; i++) {
-		PyObject *obj = PyInt_FromLong(rfds[i]);
+		PyObject *obj = PyLong_FromLong(rfds[i]);
 		if (!obj)
 			goto bail;
 		PyList_SET_ITEM(rfdslist, i, obj);
 	}


More information about the Mercurial-devel mailing list