[pypy-svn] r69512 - pypy/trunk/lib-python/modified-2.5.2/test

arigo at codespeak.net arigo at codespeak.net
Sun Nov 22 20:12:41 CET 2009


Author: arigo
Date: Sun Nov 22 20:12:39 2009
New Revision: 69512

Modified:
   pypy/trunk/lib-python/modified-2.5.2/test/test_subprocess.py
Log:
This "except ImportError" means that the code here catches and ignores
failed attempts at importing 'resource'.  However, it does not work,
because in that case it gets an UnboundLocalError on 'resource.error'.
Must be factored in two distinct try:excepts.


Modified: pypy/trunk/lib-python/modified-2.5.2/test/test_subprocess.py
==============================================================================
--- pypy/trunk/lib-python/modified-2.5.2/test/test_subprocess.py	(original)
+++ pypy/trunk/lib-python/modified-2.5.2/test/test_subprocess.py	Sun Nov 22 20:12:39 2009
@@ -485,10 +485,13 @@
             """
             try:
                 import resource
+            except ImportError:
+                return None
+            try:
                 old_limit = resource.getrlimit(resource.RLIMIT_CORE)
                 resource.setrlimit(resource.RLIMIT_CORE, (0,0))
                 return old_limit
-            except (ImportError, ValueError, resource.error):
+            except (ValueError, resource.error):
                 return None
 
         def _unsuppress_core_files(self, old_limit):
@@ -497,8 +500,11 @@
                 return
             try:
                 import resource
+            except ImportError:
+                return
+            try:
                 resource.setrlimit(resource.RLIMIT_CORE, old_limit)
-            except (ImportError, ValueError, resource.error):
+            except (ValueError, resource.error):
                 return
 
         def test_run_abort(self):



More information about the Pypy-commit mailing list