Details
Details
- Reviewers
pulkit - Group Reviewers
hg-reviewers - Commits
- rHGf3fa10a5877d: py3: use integer division for the value passed to xrange
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
pulkit |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/pure/osutil.py (4 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Rodrigo Damazio Bovendorp | Jun 25 2019, 10:30 PM |
# osutil.py - pure Python version of osutil.c | # osutil.py - pure Python version of osutil.c | ||||
# | # | ||||
# Copyright 2009 Matt Mackall <mpm@selenic.com> and others | # Copyright 2009 Matt Mackall <mpm@selenic.com> and others | ||||
# | # | ||||
# This software may be used and distributed according to the terms of the | # This software may be used and distributed according to the terms of the | ||||
# GNU General Public License version 2 or any later version. | # GNU General Public License version 2 or any later version. | ||||
from __future__ import absolute_import | from __future__ import absolute_import, division | ||||
import ctypes | import ctypes | ||||
import ctypes.util | import ctypes.util | ||||
import os | import os | ||||
import socket | import socket | ||||
import stat as statmod | import stat as statmod | ||||
from .. import ( | from .. import ( | ||||
# portable CMSG_NXTHDR() with ctypes. | # portable CMSG_NXTHDR() with ctypes. | ||||
cmsg = _CMSG_FIRSTHDR(msgh) | cmsg = _CMSG_FIRSTHDR(msgh) | ||||
if not cmsg: | if not cmsg: | ||||
return [] | return [] | ||||
if (cmsg.cmsg_level != socket.SOL_SOCKET or | if (cmsg.cmsg_level != socket.SOL_SOCKET or | ||||
cmsg.cmsg_type != _SCM_RIGHTS): | cmsg.cmsg_type != _SCM_RIGHTS): | ||||
return [] | return [] | ||||
rfds = ctypes.cast(cmsg.cmsg_data, ctypes.POINTER(ctypes.c_int)) | rfds = ctypes.cast(cmsg.cmsg_data, ctypes.POINTER(ctypes.c_int)) | ||||
rfdscount = ((cmsg.cmsg_len - _cmsghdr.cmsg_data.offset) / | rfdscount = ((cmsg.cmsg_len - _cmsghdr.cmsg_data.offset) // | ||||
ctypes.sizeof(ctypes.c_int)) | ctypes.sizeof(ctypes.c_int)) | ||||
return [rfds[i] for i in pycompat.xrange(rfdscount)] | return [rfds[i] for i in pycompat.xrange(rfdscount)] | ||||
else: | else: | ||||
import msvcrt | import msvcrt | ||||
_kernel32 = ctypes.windll.kernel32 | _kernel32 = ctypes.windll.kernel32 | ||||