diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2009-09-11 23:50:28 +0200 |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2009-09-11 23:50:28 +0200 |
commit | 96c97c7b38ffe815a6f1cc6e76fea1d627610d60 (patch) | |
tree | 38dee9b621948b1e335679703bc71f4783d1500e /setuptools | |
parent | 6f3378c098a481588f5ec5813060376351e5a576 (diff) | |
download | external_python_setuptools-96c97c7b38ffe815a6f1cc6e76fea1d627610d60.tar.gz external_python_setuptools-96c97c7b38ffe815a6f1cc6e76fea1d627610d60.tar.bz2 external_python_setuptools-96c97c7b38ffe815a6f1cc6e76fea1d627610d60.zip |
Conditionalize _file processing.
--HG--
branch : distribute
extra : rebase_source : fd07ce0e0541a269a88596e985884f688c86185e
Diffstat (limited to 'setuptools')
-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", |