Author: Philip Jenvey <[email protected]>
Branch: py3k
Changeset: r59128:558fa21fa080
Date: 2012-11-29 11:47 -0800
http://bitbucket.org/pypy/pypy/changeset/558fa21fa080/
Log: cleanup exec tests & error message
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -1517,7 +1517,7 @@
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):
diff --git a/pypy/interpreter/test/test_exec.py
b/pypy/interpreter/test/test_exec.py
--- a/pypy/interpreter/test/test_exec.py
+++ b/pypy/interpreter/test/test_exec.py
@@ -126,9 +126,6 @@
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
@@ -140,8 +137,12 @@
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:
diff --git a/pypy/module/__builtin__/test/test_builtin.py
b/pypy/module/__builtin__/test/test_builtin.py
--- a/pypy/module/__builtin__/test/test_builtin.py
+++ b/pypy/module/__builtin__/test/test_builtin.py
@@ -482,19 +482,6 @@
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")
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit