[Python-checkins] r80621 - sandbox/trunk/setuptools/setuptools/sandbox.py

phillip.eby python-checkins at python.org
Thu Apr 29 18:07:56 CEST 2010


Author: phillip.eby
Date: Thu Apr 29 18:07:56 2010
New Revision: 80621

Log:
Fix a problem with sandbox swapping 'open' and 'file' builtins.
Support sandbox access to os.devnull.


Modified:
   sandbox/trunk/setuptools/setuptools/sandbox.py

Modified: sandbox/trunk/setuptools/setuptools/sandbox.py
==============================================================================
--- sandbox/trunk/setuptools/setuptools/sandbox.py	(original)
+++ sandbox/trunk/setuptools/setuptools/sandbox.py	Thu Apr 29 18:07:56 2010
@@ -105,8 +105,8 @@
             return func()
         finally:
             self._active = False
-            __builtin__.open = _file
-            __builtin__.file = _open
+            __builtin__.open = _open
+            __builtin__.file = _file
             self._copy(_os)
 
     def _mk_dual_path_wrapper(name):
@@ -203,10 +203,10 @@
             self._violation("open", path, mode, *args, **kw)
         return _open(path,mode,*args,**kw)
 
-    def tmpnam(self):
-        self._violation("tmpnam")
+    def tmpnam(self): self._violation("tmpnam")
 
     def _ok(self,path):
+        if hasattr(_os,'devnull') and path==_os.devnull: return True
         active = self._active
         try:
             self._active = False


More information about the Python-checkins mailing list