Description: Avoid UnboundLocalError if resource isn't importable
Author: Stefano Rivera <stefanor@debian.org>
Forwarded: no
Last-Update: 2011-12-20

--- a/lib-python/2.7/test/test_subprocess.py
+++ b/lib-python/2.7/test/test_subprocess.py
@@ -627,9 +627,12 @@
         """Try to save previous ulimit, then set it to (0, 0)."""
         try:
             import resource
-            self.old_limit = resource.getrlimit(resource.RLIMIT_CORE)
-            resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
-        except (ImportError, ValueError, resource.error):
+            try:
+                self.old_limit = resource.getrlimit(resource.RLIMIT_CORE)
+                resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
+            except (ValueError, resource.error):
+                pass
+        except ImportError:
             pass
 
         if sys.platform == 'darwin':
