Commit 457f9578 authored by Hanno Schlichting's avatar Hanno Schlichting

Applied patch from pjenvey. This closes #6.

--HG--
branch : distribute
extra : rebase_source : 96ce51b3a70155a8b87de8ed0f72de8e12a7a27c
parent 334f5b69
import os, sys, __builtin__, tempfile, operator
_os = sys.modules[os.name]
_file = file
_open = open
from distutils.errors import DistutilsError
__all__ = [
......@@ -58,12 +59,14 @@ class AbstractSandbox:
"""Run 'func' under os sandboxing"""
try:
self._copy(self)
__builtin__.open = __builtin__.file = self._open
__builtin__.file = self._file
__builtin__.open = self._open
self._active = True
return func()
finally:
self._active = False
__builtin__.open = __builtin__.file = _open
__builtin__.file = _file
__builtin__.open = _open
self._copy(_os)
......@@ -88,7 +91,8 @@ class AbstractSandbox:
return original(path,*args,**kw)
return wrap
_open = _mk_single_path_wrapper('file', _open)
_file = _mk_single_path_wrapper('file', _file)
_open = _mk_single_path_wrapper('open', _open)
for name in [
"stat", "listdir", "chdir", "open", "chmod", "chown", "mkdir",
"remove", "unlink", "rmdir", "utime", "lchown", "chroot", "lstat",
......
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