Author: Antonio Cuni <anto.c...@gmail.com>
Branch: py3k
Changeset: r52883:b8fbd7d49566
Date: 2012-02-24 20:05 +0100
http://bitbucket.org/pypy/pypy/changeset/b8fbd7d49566/

Log:    kill execfile() and its tests (sigh\!)

diff --git a/pypy/module/__builtin__/__init__.py 
b/pypy/module/__builtin__/__init__.py
--- a/pypy/module/__builtin__/__init__.py
+++ b/pypy/module/__builtin__/__init__.py
@@ -12,7 +12,6 @@
     expose__file__attribute = False
 
     appleveldefs = {
-        'execfile'      : 'app_io.execfile',
         'input'         : 'app_io.input',
         'print'         : 'app_io.print_',
 
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
@@ -5,28 +5,6 @@
 
 import sys
 
-def execfile(filename, glob=None, loc=None):
-    """execfile(filename[, globals[, locals]])
-
-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 None:
-        # Warning this is at hidden_applevel
-        glob = globals()
-        if loc is None:
-            loc = locals()
-    elif loc is None:
-        loc = glob
-    f = open(filename, 'rU')
-    try:
-        source = f.read()
-    finally:
-        f.close()
-    #Don't exec the source directly, as this loses the filename info
-    co = compile(source.rstrip()+"\n", filename, 'exec')
-    exec(co, glob, loc)
-
 def _write_prompt(stdout, prompt):
     print(prompt, file=stdout, end='')
     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
@@ -676,47 +676,3 @@
                 return {'a':2}
             __dict__ = property(fget=getDict)
         assert vars(C_get_vars()) == {'a':2}
-
-
-class TestInternal:
-    def test_execfile(self, space):
-        from pypy.tool.udir import udir
-        fn = str(udir.join('test_execfile'))
-        f = open(fn, 'w')
-        print >>f, "i=42"
-        f.close()
-
-        w_execfile = space.builtin.get("execfile")
-        w_dict = space.newdict()
-        space.call_function(w_execfile,
-            space.wrap(fn), w_dict, space.w_None)
-        w_value = space.getitem(w_dict, space.wrap('i'))
-        assert space.eq_w(w_value, space.wrap(42))
-
-    def test_execfile_different_lineendings(self, space): 
-        from pypy.tool.udir import udir
-        d = udir.ensure('lineending', dir=1)
-        dos = d.join('dos.py') 
-        f = dos.open('wb') 
-        f.write("x=3\r\n\r\ny=4\r\n")
-        f.close() 
-        space.appexec([space.wrap(str(dos))], """
-            (filename): 
-                d = {}
-                execfile(filename, d)
-                assert d['x'] == 3
-                assert d['y'] == 4
-        """)
-
-        unix = d.join('unix.py')
-        f = unix.open('wb') 
-        f.write("x=5\n\ny=6\n")
-        f.close() 
-
-        space.appexec([space.wrap(str(unix))], """
-            (filename): 
-                d = {}
-                execfile(filename, d)
-                assert d['x'] == 5
-                assert d['y'] == 6
-        """)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to