# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 2016-08-03 19:02:19 # Node ID f15f31505f12bff1e0401ee63d3420ee157afc95 # Parent 00269c6e4f6e6dbdaff4ef89e9f6c105944f28d6 py3: use unicode literals in pure/osutil.py The first element of _fields_ tuples must be a str in Python 3. Also fix some function calls that were also expecting str. diff --git a/mercurial/pure/osutil.py b/mercurial/pure/osutil.py --- a/mercurial/pure/osutil.py +++ b/mercurial/pure/osutil.py @@ -173,30 +173,30 @@ if os.name != 'nt': 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) _recvmsg = getattr(_libc, 'recvmsg', None) if _recvmsg: _recvmsg.restype = getattr(ctypes, 'c_ssize_t', ctypes.c_long) diff --git a/tests/test-check-py3-compat.t b/tests/test-check-py3-compat.t --- a/tests/test-check-py3-compat.t +++ b/tests/test-check-py3-compat.t @@ -122,53 +122,51 @@ mercurial/hook.py: error importing: str expected, not bytes (error at i18n.py:*) (glob) mercurial/httpconnection.py: error importing: str expected, not bytes (error at i18n.py:*) (glob) mercurial/httppeer.py: error importing: str expected, not bytes (error at i18n.py:*) (glob) - mercurial/keepalive.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/localrepo.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/lock.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/mail.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) + mercurial/keepalive.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) + mercurial/localrepo.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) + mercurial/lock.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) + mercurial/mail.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) mercurial/manifest.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) - mercurial/match.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) + mercurial/match.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) mercurial/mdiff.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) - mercurial/merge.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/minirst.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/namespaces.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) + mercurial/merge.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) + mercurial/minirst.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) + mercurial/namespaces.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) mercurial/obsolete.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) - mercurial/patch.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/pathutil.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/peer.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) + mercurial/patch.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) + mercurial/pathutil.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) + mercurial/peer.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) mercurial/pure/mpatch.py: error importing module: cannot import name 'pycompat' (line *) (glob) mercurial/pure/osutil.py: error importing module: cannot import name 'policy' (line *) (glob) mercurial/pure/parsers.py: error importing module: No module named 'mercurial.pure.node' (line *) (glob) - mercurial/pushkey.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/pvec.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/registrar.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) + mercurial/pushkey.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) + mercurial/pvec.py: error importing: getattr(): attribute name must be string (error at pycompat.py:*) (glob) + mercurial/registrar.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) mercurial/repair.py: error importing module: invalid syntax (bundle2.py, line *) (line *) (glob) - mercurial/repoview.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/revlog.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/revset.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/scmposix.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/scmutil.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) + mercurial/repoview.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) + mercurial/revlog.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) + mercurial/revset.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) + mercurial/scmutil.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) mercurial/scmwindows.py: error importing module: No module named '_winreg' (line *) (glob) - mercurial/similar.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/simplemerge.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/sshpeer.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/sshserver.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/sslutil.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/statichttprepo.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/store.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/streamclone.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/subrepo.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/tagmerge.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/tags.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/templatefilters.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/templatekw.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/templater.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/transaction.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/ui.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/unionrepo.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/url.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/util.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) - mercurial/verify.py: error importing: '_fields_' must be a sequence of (name, C type) pairs (error at osutil.py:*) (glob) + mercurial/similar.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) + mercurial/simplemerge.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) + mercurial/sshpeer.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) + mercurial/sshserver.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) + mercurial/sslutil.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) + mercurial/statichttprepo.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) + mercurial/store.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) + mercurial/streamclone.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) + mercurial/subrepo.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) + mercurial/tagmerge.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) + mercurial/tags.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) + mercurial/templatefilters.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) + mercurial/templatekw.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) + mercurial/templater.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) + mercurial/transaction.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) + mercurial/ui.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) + mercurial/unionrepo.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) + mercurial/url.py: error importing: getattr(): attribute name must be string (error at util.py:*) (glob) + mercurial/verify.py: error importing: attribute name must be string, not 'bytes' (error at mdiff.py:*) (glob) mercurial/win32.py: error importing module: No module named 'msvcrt' (line *) (glob) mercurial/windows.py: error importing module: No module named '_winreg' (line *) (glob) mercurial/wireproto.py: error importing module: invalid syntax (bundle2.py, line *) (line *) (glob)