[Zope3-checkins] SVN: Zope3/trunk/src/zope/security/untrustedpython/builtins.py Ignoring missing attributes in __builtins__. I'm running into a case where 'copyright' isn't in __builtins__ (using py2exe) and it seems reasonable to let this and other cases of missing builtins pass.

Garrett Smith garrett at mojave-corp.com
Wed Mar 9 13:58:22 EST 2005


Log message for revision 29428:
  Ignoring missing attributes in __builtins__. I'm running into a case where 'copyright' isn't in __builtins__ (using py2exe) and it seems reasonable to let this and other cases of missing builtins pass.

Changed:
  U   Zope3/trunk/src/zope/security/untrustedpython/builtins.py

-=-
Modified: Zope3/trunk/src/zope/security/untrustedpython/builtins.py
===================================================================
--- Zope3/trunk/src/zope/security/untrustedpython/builtins.py	2005-03-09 18:53:17 UTC (rev 29427)
+++ Zope3/trunk/src/zope/security/untrustedpython/builtins.py	2005-03-09 18:58:22 UTC (rev 29428)
@@ -21,7 +21,7 @@
 def SafeBuiltins():
 
     builtins = {}
-    
+
     from zope.security.checker import NamesChecker
     import __builtin__
 
@@ -65,12 +65,16 @@
         #dir,
         ]:
 
-        value = getattr(__builtin__, name)
-        if isinstance(value, type):
-            value = ProxyFactory(value, _builtinTypeChecker)
+        try:
+            value = getattr(__builtin__, name)
+        except AttributeError:
+            pass
         else:
-            value = ProxyFactory(value)
-        builtins[name] = value
+            if isinstance(value, type):
+                value = ProxyFactory(value, _builtinTypeChecker)
+            else:
+                value = ProxyFactory(value)
+            builtins[name] = value
 
     from sys import modules
 



More information about the Zope3-Checkins mailing list