From f5cad63054a97ed4ff93c166e4ed7375bb183659 Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Mon, 8 Feb 2010 21:21:23 -0800 Subject: [PATCH] Fix import errors in green.subprocess relating to version dependencies. --- eventlet/green/subprocess.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/eventlet/green/subprocess.py b/eventlet/green/subprocess.py index 0f31599..293daa4 100644 --- a/eventlet/green/subprocess.py +++ b/eventlet/green/subprocess.py @@ -58,10 +58,18 @@ class Popen(subprocess_orig.Popen): # don't want to rewrite the original _communicate() method, we # just want a version that uses eventlet.green.select.select() # instead of select.select(). - _communicate = new.function(subprocess_orig.Popen._communicate.im_func.func_code, - globals()) + try: + _communicate = new.function(subprocess_orig.Popen._communicate.im_func.func_code, + globals()) + except AttributeError: + # 2.4 only has communicate + communicate = new.function(subprocess_orig.Popen.communicate.im_func.func_code, + globals()) # Borrow subprocess.call() and check_call(), but patch them so they reference # OUR Popen class rather than subprocess.Popen. call = new.function(subprocess_orig.call.func_code, globals()) -check_call = new.function(subprocess_orig.check_call.func_code, globals()) +try: + check_call = new.function(subprocess_orig.check_call.func_code, globals()) +except AttributeError: + pass # check_call added in 2.5