summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvery Pennarun <apenwarr@gmail.com>2010-10-01 18:40:53 -0700
committerAvery Pennarun <apenwarr@gmail.com>2010-10-01 19:26:56 -0700
commit52fbb2ebbea3fef2c4876c16a93408c1dba9b28a (patch)
treee670f16e6552fee60974f7412b9b8cc4363022c4
parent76d576a37585885527635c7ee7fb3935870573a9 (diff)
compat/ssubprocess.py: some python versions don't have os.closerange().
Like python2.5 on Debian. It might be a MacOS extension or something. So much for the comment in subprocess.py that said "keep this compatible with python 2.2."
-rw-r--r--compat/ssubprocess.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/compat/ssubprocess.py b/compat/ssubprocess.py
index 240f890..ee6b8da 100644
--- a/compat/ssubprocess.py
+++ b/compat/ssubprocess.py
@@ -531,6 +531,17 @@ def list2cmdline(seq):
return ''.join(result)
+def _closerange(start, max):
+ try:
+ os.closerange(start, max)
+ except AttributeError:
+ for i in xrange(start, max):
+ try:
+ os.close(i)
+ except:
+ pass
+
+
class Popen(object):
def __init__(self, args, bufsize=0, executable=None,
stdin=None, stdout=None, stderr=None,
@@ -989,8 +1000,8 @@ class Popen(object):
def _close_fds(self, but):
- os.closerange(3, but)
- os.closerange(but + 1, MAXFD)
+ _closerange(3, but)
+ _closerange(but + 1, MAXFD)
def _execute_child(self, args, executable, preexec_fn, close_fds,