[PATCH] run-tests.py: avoid using popen2.Popen4 - use subprocess instead
Mads Kiilerich
mads at kiilerich.com
Fri Feb 27 12:11:03 CST 2009
# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1235758238 -3600
# Node ID 6e1af485c84efbf2dae522c3dbd60532be3e0f31
# Parent ab33356cda81cc0d0de969af29d2c2b7a460a30e
run-tests.py: avoid using popen2.Popen4 - use subprocess instead
Use subprocess to emulate Popen4 if available - similar to how it is done in
util.py.
Using popen2 under python 2.6 gives
DeprecationWarning: The popen2 module is deprecated. Use the subprocess module.
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -11,7 +11,22 @@
import errno
import optparse
import os
-import popen2
+try:
+ import subprocess
+ subprocess.Popen # trigger ImportError early
+ closefds = os.name == 'posix'
+ def Popen4(cmd, bufsize=-1):
+ p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
+ close_fds=closefds,
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ p.fromchild = p.stdout
+ p.tochild = p.stdin
+ p.childerr = p.stderr
+ return p
+except ImportError:
+ subprocess = None
+ from popen2 import Popen4
import shutil
import signal
import sys
@@ -281,7 +296,7 @@
if ret == None:
ret = 0
else:
- proc = popen2.Popen4(cmd)
+ proc = Popen4(cmd)
try:
output = ''
proc.tochild.close()
More information about the Mercurial-devel
mailing list