diff options
author | tarek <none@none> | 2009-09-20 14:48:47 +0200 |
---|---|---|
committer | tarek <none@none> | 2009-09-20 14:48:47 +0200 |
commit | ba84419dfc63e5f535faead38ee9fb60306a079c (patch) | |
tree | c489fe218f0e43d14f3a9e8f8c14517439d4fde0 /setuptools/sandbox.py | |
parent | 1219c326683905695fbdf60c22367129075d2f8d (diff) | |
parent | 95159c09e5bb2d1dc1f0ccf89ccbe90ecc6871a0 (diff) | |
download | external_python_setuptools-ba84419dfc63e5f535faead38ee9fb60306a079c.tar.gz external_python_setuptools-ba84419dfc63e5f535faead38ee9fb60306a079c.tar.bz2 external_python_setuptools-ba84419dfc63e5f535faead38ee9fb60306a079c.zip |
merge dance
--HG--
branch : distribute
extra : rebase_source : e0fc1e252a506a6a751f9557d4a01580e1cbbdfa
Diffstat (limited to 'setuptools/sandbox.py')
-rwxr-xr-x | setuptools/sandbox.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/setuptools/sandbox.py b/setuptools/sandbox.py index 11c14938..67cedde6 100755 --- a/setuptools/sandbox.py +++ b/setuptools/sandbox.py @@ -1,6 +1,9 @@ import os, sys, __builtin__, tempfile, operator _os = sys.modules[os.name] -_file = file +try: + _file = file +except NameError: + _file = None _open = open from distutils.errors import DistutilsError __all__ = [ @@ -60,13 +63,15 @@ class AbstractSandbox: """Run 'func' under os sandboxing""" try: self._copy(self) - __builtin__.file = self._file + if _file: + __builtin__.file = self._file __builtin__.open = self._open self._active = True return func() finally: self._active = False - __builtin__.file = _file + if _file: + __builtin__.file = _file __builtin__.open = _open self._copy(_os) @@ -92,7 +97,8 @@ class AbstractSandbox: return original(path,*args,**kw) return wrap - _file = _mk_single_path_wrapper('file', _file) + if _file: + _file = _mk_single_path_wrapper('file', _file) _open = _mk_single_path_wrapper('open', _open) for name in [ "stat", "listdir", "chdir", "open", "chmod", "chown", "mkdir", |