Commit d3a345a2 authored by Benjamin Peterson's avatar Benjamin Peterson

merge 3.2

parents 10a6ddb0 964561bb
...@@ -18,6 +18,12 @@ try: ...@@ -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,11 +830,11 @@ class _SuppressCoreFiles(object): ...@@ -824,11 +830,11 @@ 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)."""
if resource is not None:
try: try:
import resource
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':
...@@ -850,10 +856,10 @@ class _SuppressCoreFiles(object): ...@@ -850,10 +856,10 @@ 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
if resource is not None:
try: try:
import resource
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment