Patchwork [3,of,8] pure/osutil: c_ssize_t is only available in Python >= 2.7

login
register
mail settings
Submitter Bryan O'Sullivan
Date Dec. 23, 2015, 6:24 a.m.
Message ID <84a069c3cf4bfcc56cd8.1450851881@bryano-mbp.local>
Download mbox | patch
Permalink /patch/12267/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Bryan O'Sullivan - Dec. 23, 2015, 6:24 a.m.
# HG changeset patch
# User Bryan O'Sullivan <bos@serpentine.com>
# Date 1450849086 28800
#      Tue Dec 22 21:38:06 2015 -0800
# Node ID 84a069c3cf4bfcc56cd889a7c03ef974d3913b98
# Parent  a29971f960ad845a4ffac06d7d1b7901d05268f7
pure/osutil: c_ssize_t is only available in Python >= 2.7
Yuya Nishihara - Dec. 23, 2015, 1:06 p.m.
On Tue, 22 Dec 2015 22:24:41 -0800, Bryan O'Sullivan wrote:
> # HG changeset patch
> # User Bryan O'Sullivan <bos@serpentine.com>
> # Date 1450849086 28800
> #      Tue Dec 22 21:38:06 2015 -0800
> # Node ID 84a069c3cf4bfcc56cd889a7c03ef974d3913b98
> # Parent  a29971f960ad845a4ffac06d7d1b7901d05268f7
> pure/osutil: c_ssize_t is only available in Python >= 2.7
> 
> diff --git a/mercurial/pure/osutil.py b/mercurial/pure/osutil.py
> --- a/mercurial/pure/osutil.py
> +++ b/mercurial/pure/osutil.py
> @@ -105,7 +105,7 @@ if os.name != 'nt':
>  
>      _libc = ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True)
>      _recvmsg = _libc.recvmsg
> -    _recvmsg.restype = ctypes.c_ssize_t
> +    _recvmsg.restype = getattr(ctypes, 'c_ssize_t', ctypes.c_long)

Oh, thanks. Pushed 1-3 to the clowncopter.

Patch

diff --git a/mercurial/pure/osutil.py b/mercurial/pure/osutil.py
--- a/mercurial/pure/osutil.py
+++ b/mercurial/pure/osutil.py
@@ -105,7 +105,7 @@  if os.name != 'nt':
 
     _libc = ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True)
     _recvmsg = _libc.recvmsg
-    _recvmsg.restype = ctypes.c_ssize_t
+    _recvmsg.restype = getattr(ctypes, 'c_ssize_t', ctypes.c_long)
     _recvmsg.argtypes = (ctypes.c_int, ctypes.POINTER(_msghdr), ctypes.c_int)
 
     def _CMSG_FIRSTHDR(msgh):