Commits

Philip Jenvey committed 558fa21

cleanup exec tests & error message

Comments (0)

Files changed (3)

pypy/interpreter/pyopcode.py

 
         if not isinstance(globals, dict):
             raise TypeError(
-                "exec() arg 2 must be a dictionary or None, not %s" %
+                "exec() arg 2 must be a dict or None, not %s" %
                 type(globals).__name__)
         globals.setdefault('__builtins__', builtin)
         if not isinstance(locals, dict):

pypy/interpreter/test/test_exec.py

         raises(SyntaxError, x)
 
     def test_mapping_as_locals(self):
-        import sys
-        if sys.version_info < (2,5) or not hasattr(sys, 'pypy_objspaceclass'):
-            skip("need CPython 2.5 or PyPy for non-dictionaries in exec statements")
         class M(object):
             def __getitem__(self, key):
                 return key
         m.result = {}
         exec("x=m", {}, m)
         assert m.result == {'x': 'm'}
-        exec("y=n", m)
-        assert m.result == {'x': 'm', 'y': 'n'}
+        try:
+            exec("y=n", m)
+        except TypeError:
+            pass
+        else:
+            assert False, 'Expected TypeError'
 
     def test_filename(self):
         try:

pypy/module/__builtin__/test/test_builtin.py

         raises(ValueError, compile, "\n", "<string>", "exec", 0xff)
         raises(TypeError, compile, '1+2', 12, 34)
 
-        class M:
-            def __getitem__(self, key):
-                pass
-            def keys(self):
-                pass
-        m = M()
-        try:
-            exec('pass', m)
-        except TypeError:
-            pass
-        else:
-            assert False, 'Expected TypeError'
-
     def test_unicode_encoding_compile(self):
         code = "# -*- coding: utf-8 -*-\npass\n"
         compile(code, "tmp", "exec")