[pypy-svn] r16740 - pypy/release/0.7.x/pypy/interpreter

ac at codespeak.net ac at codespeak.net
Sat Aug 27 13:08:25 CEST 2005


Author: ac
Date: Sat Aug 27 13:08:25 2005
New Revision: 16740

Modified:
   pypy/release/0.7.x/pypy/interpreter/pyopcode.py
Log:
Accept non-dict objects as globals/locals to exec as long as they have __getitem__.

Modified: pypy/release/0.7.x/pypy/interpreter/pyopcode.py
==============================================================================
--- pypy/release/0.7.x/pypy/interpreter/pyopcode.py	(original)
+++ pypy/release/0.7.x/pypy/interpreter/pyopcode.py	Sat Aug 27 13:08:25 2005
@@ -874,12 +874,14 @@
             locals = globals
 
         if not isinstance(globals, dict):
-            if hasattr(globals, '__getitem__'):
+            if not hasattr(globals, '__getitem__'):
                 raise TypeError("exec: arg 2 must be a dictionary or None")
-        if '__builtins__' not in globals:
+        try:
+            globals['__builtins__']
+        except KeyError:
             globals['__builtins__'] = builtin
         if not isinstance(locals, dict):
-            if hasattr(locals, '__getitem__'):
+            if not hasattr(locals, '__getitem__'):
                 raise TypeError("exec: arg 3 must be a dictionary or None")
 
         if not isinstance(prog, codetype):



More information about the Pypy-commit mailing list