comparison mercurial/posix.py @ 37459:90c5ca718781

procutil: rewrite popen() as a subprocess.Popen wrapper (issue4746) (API) os.popen() of Python 3 is not the popen() we want. First, it doesn't accept command in bytes. Second, a returned stream is always wrapped by TextIO. So we have to reimplement our popen(). Fortunately, this fixes the bug 4746 since ours returns an exit code compatible with explainexit(). .. api:: ``procutil.popen()`` no longer supports text mode I/O.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 07 Apr 2018 21:09:21 +0900
parents e24802ea8dbd
children a6c6b7beb025
comparison
equal deleted inserted replaced
37458:00e4bd97b095 37459:90c5ca718781
467 return pycompat.shlexsplit(s, posix=True) 467 return pycompat.shlexsplit(s, posix=True)
468 468
469 def quotecommand(cmd): 469 def quotecommand(cmd):
470 return cmd 470 return cmd
471 471
472 def popen(command, mode='r'):
473 return os.popen(command, mode)
474
475 def testpid(pid): 472 def testpid(pid):
476 '''return False if pid dead, True if running or not sure''' 473 '''return False if pid dead, True if running or not sure'''
477 if pycompat.sysplatform == 'OpenVMS': 474 if pycompat.sysplatform == 'OpenVMS':
478 return True 475 return True
479 try: 476 try: