mercurial/win32.py
changeset 43077 687b865b95ad
parent 43076 2372284d9457
child 43503 313e3a279828
equal deleted inserted replaced
43076:2372284d9457 43077:687b865b95ad
   402 
   402 
   403     certctx = _crypt32.CertCreateCertificateContext(
   403     certctx = _crypt32.CertCreateCertificateContext(
   404         X509_ASN_ENCODING, cert, len(cert)
   404         X509_ASN_ENCODING, cert, len(cert)
   405     )
   405     )
   406     if certctx is None:
   406     if certctx is None:
   407         _raiseoserror('CertCreateCertificateContext')
   407         _raiseoserror(b'CertCreateCertificateContext')
   408 
   408 
   409     flags = 0
   409     flags = 0
   410 
   410 
   411     if not build:
   411     if not build:
   412         flags |= 0x100  # CERT_CHAIN_DISABLE_AUTH_ROOT_AUTO_UPDATE
   412         flags |= 0x100  # CERT_CHAIN_DISABLE_AUTH_ROOT_AUTO_UPDATE
   421             ctypes.byref(chainpara),
   421             ctypes.byref(chainpara),
   422             flags,
   422             flags,
   423             None,  # pvReserved
   423             None,  # pvReserved
   424             ctypes.byref(pchainctx),
   424             ctypes.byref(pchainctx),
   425         ):
   425         ):
   426             _raiseoserror('CertGetCertificateChain')
   426             _raiseoserror(b'CertGetCertificateChain')
   427 
   427 
   428         chainctx = pchainctx.contents
   428         chainctx = pchainctx.contents
   429 
   429 
   430         return chainctx.dwErrorStatus & CERT_TRUST_IS_PARTIAL_CHAIN == 0
   430         return chainctx.dwErrorStatus & CERT_TRUST_IS_PARTIAL_CHAIN == 0
   431     finally:
   431     finally:
   541     volume = getvolumename(path)
   541     volume = getvolumename(path)
   542 
   542 
   543     t = _kernel32.GetDriveTypeA(volume)
   543     t = _kernel32.GetDriveTypeA(volume)
   544 
   544 
   545     if t == _DRIVE_REMOTE:
   545     if t == _DRIVE_REMOTE:
   546         return 'cifs'
   546         return b'cifs'
   547     elif t not in (
   547     elif t not in (
   548         _DRIVE_REMOVABLE,
   548         _DRIVE_REMOVABLE,
   549         _DRIVE_FIXED,
   549         _DRIVE_FIXED,
   550         _DRIVE_CDROM,
   550         _DRIVE_CDROM,
   551         _DRIVE_RAMDISK,
   551         _DRIVE_RAMDISK,
   661     si = _STARTUPINFO()
   661     si = _STARTUPINFO()
   662     si.cb = ctypes.sizeof(_STARTUPINFO)
   662     si.cb = ctypes.sizeof(_STARTUPINFO)
   663 
   663 
   664     pi = _PROCESS_INFORMATION()
   664     pi = _PROCESS_INFORMATION()
   665 
   665 
   666     env = ''
   666     env = b''
   667     for k in encoding.environ:
   667     for k in encoding.environ:
   668         env += "%s=%s\0" % (k, encoding.environ[k])
   668         env += b"%s=%s\0" % (k, encoding.environ[k])
   669     if not env:
   669     if not env:
   670         env = '\0'
   670         env = b'\0'
   671     env += '\0'
   671     env += b'\0'
   672 
   672 
   673     args = subprocess.list2cmdline(pycompat.rapply(encoding.strfromlocal, args))
   673     args = subprocess.list2cmdline(pycompat.rapply(encoding.strfromlocal, args))
   674 
   674 
   675     # TODO: CreateProcessW on py3?
   675     # TODO: CreateProcessW on py3?
   676     res = _kernel32.CreateProcessA(
   676     res = _kernel32.CreateProcessA(
   722     # f to a random temporary name before calling os.unlink on it. This allows
   722     # f to a random temporary name before calling os.unlink on it. This allows
   723     # callers to recreate f immediately while having other readers do their
   723     # callers to recreate f immediately while having other readers do their
   724     # implicit zombie filename blocking on a temporary name.
   724     # implicit zombie filename blocking on a temporary name.
   725 
   725 
   726     for tries in pycompat.xrange(10):
   726     for tries in pycompat.xrange(10):
   727         temp = '%s-%08x' % (f, random.randint(0, 0xFFFFFFFF))
   727         temp = b'%s-%08x' % (f, random.randint(0, 0xFFFFFFFF))
   728         try:
   728         try:
   729             os.rename(f, temp)  # raises OSError EEXIST if temp exists
   729             os.rename(f, temp)  # raises OSError EEXIST if temp exists
   730             break
   730             break
   731         except OSError as e:
   731         except OSError as e:
   732             if e.errno != errno.EEXIST:
   732             if e.errno != errno.EEXIST: