Patchwork [1,of,3] osutil: use PyLongObject in recvfds

login
register
mail settings
Submitter Gregory Szorc
Date Oct. 9, 2016, 11:57 a.m.
Message ID <0cc68ebd34108cc60932.1476014242@gps-mbp.local>
Download mbox | patch
Permalink /patch/16983/
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 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.
Yuya Nishihara - Oct. 9, 2016, 1:45 p.m.
On Sun, 09 Oct 2016 13:57:22 +0200, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1476013278 -7200
> #      Sun Oct 09 13:41:18 2016 +0200
> # Node ID 0cc68ebd34108cc609328379b46522b81f840851
> # Parent  ad527a4c62ad35b84c4ad25d080ee427528966fa
> osutil: use PyLongObject in recvfds

These look good. Queued, thanks.

Patch

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);
 	}