merge 3.2

This commit is contained in:
Benjamin Peterson 2011-12-10 12:38:52 -05:00
commit d3a345a21f
1 changed files with 17 additions and 11 deletions

View File

@ -18,6 +18,12 @@ try:
except ImportError: except ImportError:
gc = None gc = None
try:
import resource
except ImportError:
resource = None
mswindows = (sys.platform == "win32") mswindows = (sys.platform == "win32")
# #
@ -824,12 +830,12 @@ class _SuppressCoreFiles(object):
def __enter__(self): def __enter__(self):
"""Try to save previous ulimit, then set it to (0, 0).""" """Try to save previous ulimit, then set it to (0, 0)."""
try: if resource is not None:
import resource try:
self.old_limit = resource.getrlimit(resource.RLIMIT_CORE) self.old_limit = resource.getrlimit(resource.RLIMIT_CORE)
resource.setrlimit(resource.RLIMIT_CORE, (0, 0)) resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
except (ImportError, ValueError, resource.error): except (ValueError, resource.error):
pass pass
if sys.platform == 'darwin': if sys.platform == 'darwin':
# Check if the 'Crash Reporter' on OSX was configured # Check if the 'Crash Reporter' on OSX was configured
@ -850,11 +856,11 @@ class _SuppressCoreFiles(object):
"""Return core file behavior to default.""" """Return core file behavior to default."""
if self.old_limit is None: if self.old_limit is None:
return return
try: if resource is not None:
import resource try:
resource.setrlimit(resource.RLIMIT_CORE, self.old_limit) resource.setrlimit(resource.RLIMIT_CORE, self.old_limit)
except (ImportError, ValueError, resource.error): except (ValueError, resource.error):
pass pass
@unittest.skipIf(mswindows, "POSIX specific tests") @unittest.skipIf(mswindows, "POSIX specific tests")