comparison mercurial/win32.py @ 30637:344e68882cd3

py3: replace os.environ with encoding.environ (part 4 of 5)
author Pulkit Goyal <7895pulkit@gmail.com>
date Sun, 18 Dec 2016 02:06:00 +0530
parents 365812902904
children 5861bdbeb9a3
comparison
equal deleted inserted replaced
30636:f1c9fafcbf46 30637:344e68882cd3
11 import errno 11 import errno
12 import msvcrt 12 import msvcrt
13 import os 13 import os
14 import random 14 import random
15 import subprocess 15 import subprocess
16
17 from . import encoding
16 18
17 _kernel32 = ctypes.windll.kernel32 19 _kernel32 = ctypes.windll.kernel32
18 _advapi32 = ctypes.windll.advapi32 20 _advapi32 = ctypes.windll.advapi32
19 _user32 = ctypes.windll.user32 21 _user32 = ctypes.windll.user32
20 22
422 si.cb = ctypes.sizeof(_STARTUPINFO) 424 si.cb = ctypes.sizeof(_STARTUPINFO)
423 425
424 pi = _PROCESS_INFORMATION() 426 pi = _PROCESS_INFORMATION()
425 427
426 env = '' 428 env = ''
427 for k in os.environ: 429 for k in encoding.environ:
428 env += "%s=%s\0" % (k, os.environ[k]) 430 env += "%s=%s\0" % (k, encoding.environ[k])
429 if not env: 431 if not env:
430 env = '\0' 432 env = '\0'
431 env += '\0' 433 env += '\0'
432 434
433 args = subprocess.list2cmdline(args) 435 args = subprocess.list2cmdline(args)
434 # Not running the command in shell mode makes Python 2.6 hang when 436 # Not running the command in shell mode makes Python 2.6 hang when
435 # writing to hgweb output socket. 437 # writing to hgweb output socket.
436 comspec = os.environ.get("COMSPEC", "cmd.exe") 438 comspec = encoding.environ.get("COMSPEC", "cmd.exe")
437 args = comspec + " /c " + args 439 args = comspec + " /c " + args
438 440
439 res = _kernel32.CreateProcessA( 441 res = _kernel32.CreateProcessA(
440 None, args, None, None, False, _CREATE_NO_WINDOW, 442 None, args, None, None, False, _CREATE_NO_WINDOW,
441 env, os.getcwd(), ctypes.byref(si), ctypes.byref(pi)) 443 env, os.getcwd(), ctypes.byref(si), ctypes.byref(pi))