From 52fbb2ebbea3fef2c4876c16a93408c1dba9b28a Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Fri, 1 Oct 2010 18:40:53 -0700 Subject: [PATCH] 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." --- compat/ssubprocess.py | 15 +++++++++++++-- 1 file 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,