[PATCH 03 of 10] py3: use unicode literals in osutil.py

Yuya Nishihara yuya at tcha.org
Wed Aug 3 10:24:54 EDT 2016


On Wed, 03 Aug 2016 01:57:25 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit at gmail.com>
> # Date 1470165311 -19800
> #      Wed Aug 03 00:45:11 2016 +0530
> # Node ID 184be5c73cededc590bca889b6c17889345e1039
> # Parent  9c65985526ca8aff6bdb9234bbf584837ab15de8
> py3: use unicode literals in osutil.py
> 
> The first element of _files tuples must be a str in Python 3.
> Also fix some function calls that were also expecting str.

This looks okay. Can you resend with updated test output?

> --- a/mercurial/pure/osutil.py	Tue Aug 02 23:59:09 2016 +0530
> +++ b/mercurial/pure/osutil.py	Wed Aug 03 00:45:11 2016 +0530
> @@ -173,30 +173,30 @@
>  
>      class _iovec(ctypes.Structure):
>          _fields_ = [
> -            ('iov_base', ctypes.c_void_p),
> -            ('iov_len', ctypes.c_size_t),
> +            (u'iov_base', ctypes.c_void_p),
> +            (u'iov_len', ctypes.c_size_t),
>          ]
>  
>      class _msghdr(ctypes.Structure):
>          _fields_ = [
> -            ('msg_name', ctypes.c_void_p),
> -            ('msg_namelen', _socklen_t),
> -            ('msg_iov', ctypes.POINTER(_iovec)),
> -            ('msg_iovlen', _msg_iovlen_t),
> -            ('msg_control', ctypes.c_void_p),
> -            ('msg_controllen', _msg_controllen_t),
> -            ('msg_flags', ctypes.c_int),
> +            (u'msg_name', ctypes.c_void_p),
> +            (u'msg_namelen', _socklen_t),
> +            (u'msg_iov', ctypes.POINTER(_iovec)),
> +            (u'msg_iovlen', _msg_iovlen_t),
> +            (u'msg_control', ctypes.c_void_p),
> +            (u'msg_controllen', _msg_controllen_t),
> +            (u'msg_flags', ctypes.c_int),
>          ]
>  
>      class _cmsghdr(ctypes.Structure):
>          _fields_ = [
> -            ('cmsg_len', _cmsg_len_t),
> -            ('cmsg_level', ctypes.c_int),
> -            ('cmsg_type', ctypes.c_int),
> -            ('cmsg_data', ctypes.c_ubyte * 0),
> +            (u'cmsg_len', _cmsg_len_t),
> +            (u'cmsg_level', ctypes.c_int),
> +            (u'cmsg_type', ctypes.c_int),
> +            (u'cmsg_data', ctypes.c_ubyte * 0),
>          ]
>  
> -    _libc = ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True)
> +    _libc = ctypes.CDLL(ctypes.util.find_library(u'c'), use_errno=True)

I was afraid of passing unicode down to os.popen(), but it seems working
so long as the library name can be converted back to ascii.


More information about the Mercurial-devel mailing list