[pypy-commit] pypy stdlib-2.7.8: sigh, check the namespace up front to satisfy test_execfile_args
pjenvey
noreply at buildbot.pypy.org
Sat Aug 23 18:19:04 CEST 2014
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: stdlib-2.7.8
Changeset: r73005:a0a22644ed92
Date: 2014-08-23 09:17 -0700
http://bitbucket.org/pypy/pypy/changeset/a0a22644ed92/
Log: sigh, check the namespace up front to satisfy test_execfile_args
diff --git a/pypy/module/__builtin__/app_io.py b/pypy/module/__builtin__/app_io.py
--- a/pypy/module/__builtin__/app_io.py
+++ b/pypy/module/__builtin__/app_io.py
@@ -3,6 +3,7 @@
Plain Python definition of the builtin I/O-related functions.
"""
+import operator
import sys
from _ast import PyCF_ACCEPT_NULL_BYTES
@@ -12,6 +13,12 @@
Read and execute a Python script from a file.
The globals and locals are dictionaries, defaulting to the current
globals and locals. If only globals is given, locals defaults to it."""
+ if glob is not None and not isinstance(glob, dict):
+ raise TypeError("execfile() arg 2 must be a dict, not %s",
+ type(glob).__name__)
+ if loc is not None and not operator.isMappingType(loc):
+ raise TypeError("execfile() arg 3 must be a mapping, not %s",
+ type(loc).__name__)
if glob is None:
# Warning this is at hidden_applevel
glob = globals()
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
@@ -31,8 +31,10 @@
emptyfile.write('')
nullbytes = udir.join('nullbytes.py')
nullbytes.write('#abc\x00def\n')
+ nonexistent = udir.join('builtins-nonexistent')
cls.w_emptyfile = space.wrap(str(emptyfile))
cls.w_nullbytes = space.wrap(str(nullbytes))
+ cls.w_nonexistent = space.wrap(str(nonexistent))
def test_builtin_names(self):
import __builtin__
@@ -627,6 +629,9 @@
raises(TypeError, compile, src, 'mymod', 'exec', 0)
execfile(self.nullbytes) # works
+ def test_execfile_args(self):
+ raises(TypeError, execfile, self.nonexistent, {}, ())
+
def test_compile_null_bytes_flag(self):
try:
from _ast import PyCF_ACCEPT_NULL_BYTES
More information about the pypy-commit
mailing list