[Python-3000-checkins] r56940 - in python/branches/py3k: Demo/scripts/newslist.py Demo/scripts/pp.py Doc/dist/dist.tex Doc/howto/doanddont.tex Doc/lib/libdoctest.tex Doc/lib/libexcs.tex Doc/lib/libfuncs.tex Doc/lib/libuser.tex Doc/ref/ref4.tex Doc/ref/ref6.tex Doc/tut/tut.tex Lib/CGIHTTPServer.py Lib/cProfile.py Lib/distutils/core.py Lib/doctest.py Lib/lib-tk/Tkinter.py Lib/optparse.py Lib/pdb.py Lib/plat-mac/appletrawmain.py Lib/plat-mac/bundlebuilder.py Lib/profile.py Lib/test/test_builtin.py Lib/test/test_multibytecodec.py Lib/test/test_pkg.py Lib/test/test_univnewlines.py Lib/trace.py Lib/user.py Mac/Modules/ae/aescan.py Mac/Modules/ae/aesupport.py Mac/Modules/ah/ahscan.py Mac/Modules/ah/ahsupport.py Mac/Modules/app/appscan.py Mac/Modules/app/appsupport.py Mac/Modules/carbonevt/CarbonEvtscan.py Mac/Modules/carbonevt/CarbonEvtsupport.py Mac/Modules/cf/cfscan.py Mac/Modules/cf/cfsupport.py Mac/Modules/cg/cgscan.py Mac/Modules/cg/cgsupport.py Mac/Modules/cm/cmscan.py Mac/Modules/cm/cmsupport.py Mac/Modules/ctl/ctlscan.py Mac/Modules/ctl/ctlsupport.py Mac/Modules/dlg/dlgscan.py Mac/Modules/dlg/dlgsupport.py Mac/Modules/drag/dragscan.py Mac/Modules/drag/dragsupport.py Mac/Modules/evt/evtscan.py Mac/Modules/evt/evtsupport.py Mac/Modules/file/filescan.py Mac/Modules/file/filesupport.py Mac/Modules/fm/fmscan.py Mac/Modules/fm/fmsupport.py Mac/Modules/folder/folderscan.py Mac/Modules/folder/foldersupport.py Mac/Modules/help/helpscan.py Mac/Modules/help/helpsupport.py Mac/Modules/ibcarbon/IBCarbonscan.py Mac/Modules/ibcarbon/IBCarbonsupport.py Mac/Modules/icn/icnscan.py Mac/Modules/icn/icnsupport.py Mac/Modules/launch/launchscan.py Mac/Modules/launch/launchsupport.py Mac/Modules/list/listscan.py Mac/Modules/list/listsupport.py Mac/Modules/menu/menuscan.py Mac/Modules/menu/menusupport.py Mac/Modules/mlte/mltescan.py Mac/Modules/mlte/mltesupport.py Mac/Modules/osa/osascan.py Mac/Modules/osa/osasupport.py Mac/Modules/qd/qdscan.py Mac/Modules/qd/qdsupport.py Mac/Modules/qdoffs/qdoffsscan.py Mac/Modules/qdoffs/qdoffssupport.py Mac/Modules/qt/qtscan.py Mac/Modules/qt/qtsupport.py Mac/Modules/res/resscan.py Mac/Modules/res/ressupport.py Mac/Modules/scrap/scrapscan.py Mac/Modules/scrap/scrapsupport.py Mac/Modules/snd/sndscan.py Mac/Modules/snd/sndsupport.py Mac/Modules/te/tescan.py Mac/Modules/te/tesupport.py Mac/Modules/win/winscan.py Mac/Modules/win/winsupport.py Misc/NEWS Misc/Vim/python.vim Misc/cheatsheet Misc/python-mode.el Objects/fileobject.c Python/bltinmodule.c README Tools/scripts/hotshotmain.py Tools/versioncheck/README Tools/versioncheck/checkversions.py setup.py
neal.norwitz
python-3000-checkins at python.org
Sun Aug 12 02:43:33 CEST 2007
Author: neal.norwitz
Date: Sun Aug 12 02:43:29 2007
New Revision: 56940
Modified:
python/branches/py3k/Demo/scripts/newslist.py
python/branches/py3k/Demo/scripts/pp.py
python/branches/py3k/Doc/dist/dist.tex
python/branches/py3k/Doc/howto/doanddont.tex
python/branches/py3k/Doc/lib/libdoctest.tex
python/branches/py3k/Doc/lib/libexcs.tex
python/branches/py3k/Doc/lib/libfuncs.tex
python/branches/py3k/Doc/lib/libuser.tex
python/branches/py3k/Doc/ref/ref4.tex
python/branches/py3k/Doc/ref/ref6.tex
python/branches/py3k/Doc/tut/tut.tex
python/branches/py3k/Lib/CGIHTTPServer.py
python/branches/py3k/Lib/cProfile.py
python/branches/py3k/Lib/distutils/core.py
python/branches/py3k/Lib/doctest.py
python/branches/py3k/Lib/lib-tk/Tkinter.py
python/branches/py3k/Lib/optparse.py
python/branches/py3k/Lib/pdb.py
python/branches/py3k/Lib/plat-mac/appletrawmain.py
python/branches/py3k/Lib/plat-mac/bundlebuilder.py
python/branches/py3k/Lib/profile.py
python/branches/py3k/Lib/test/test_builtin.py
python/branches/py3k/Lib/test/test_multibytecodec.py
python/branches/py3k/Lib/test/test_pkg.py
python/branches/py3k/Lib/test/test_univnewlines.py
python/branches/py3k/Lib/trace.py
python/branches/py3k/Lib/user.py
python/branches/py3k/Mac/Modules/ae/aescan.py
python/branches/py3k/Mac/Modules/ae/aesupport.py
python/branches/py3k/Mac/Modules/ah/ahscan.py
python/branches/py3k/Mac/Modules/ah/ahsupport.py
python/branches/py3k/Mac/Modules/app/appscan.py
python/branches/py3k/Mac/Modules/app/appsupport.py
python/branches/py3k/Mac/Modules/carbonevt/CarbonEvtscan.py
python/branches/py3k/Mac/Modules/carbonevt/CarbonEvtsupport.py
python/branches/py3k/Mac/Modules/cf/cfscan.py
python/branches/py3k/Mac/Modules/cf/cfsupport.py
python/branches/py3k/Mac/Modules/cg/cgscan.py
python/branches/py3k/Mac/Modules/cg/cgsupport.py
python/branches/py3k/Mac/Modules/cm/cmscan.py
python/branches/py3k/Mac/Modules/cm/cmsupport.py
python/branches/py3k/Mac/Modules/ctl/ctlscan.py
python/branches/py3k/Mac/Modules/ctl/ctlsupport.py
python/branches/py3k/Mac/Modules/dlg/dlgscan.py
python/branches/py3k/Mac/Modules/dlg/dlgsupport.py
python/branches/py3k/Mac/Modules/drag/dragscan.py
python/branches/py3k/Mac/Modules/drag/dragsupport.py
python/branches/py3k/Mac/Modules/evt/evtscan.py
python/branches/py3k/Mac/Modules/evt/evtsupport.py
python/branches/py3k/Mac/Modules/file/filescan.py
python/branches/py3k/Mac/Modules/file/filesupport.py
python/branches/py3k/Mac/Modules/fm/fmscan.py
python/branches/py3k/Mac/Modules/fm/fmsupport.py
python/branches/py3k/Mac/Modules/folder/folderscan.py
python/branches/py3k/Mac/Modules/folder/foldersupport.py
python/branches/py3k/Mac/Modules/help/helpscan.py
python/branches/py3k/Mac/Modules/help/helpsupport.py
python/branches/py3k/Mac/Modules/ibcarbon/IBCarbonscan.py
python/branches/py3k/Mac/Modules/ibcarbon/IBCarbonsupport.py
python/branches/py3k/Mac/Modules/icn/icnscan.py
python/branches/py3k/Mac/Modules/icn/icnsupport.py
python/branches/py3k/Mac/Modules/launch/launchscan.py
python/branches/py3k/Mac/Modules/launch/launchsupport.py
python/branches/py3k/Mac/Modules/list/listscan.py
python/branches/py3k/Mac/Modules/list/listsupport.py
python/branches/py3k/Mac/Modules/menu/menuscan.py
python/branches/py3k/Mac/Modules/menu/menusupport.py
python/branches/py3k/Mac/Modules/mlte/mltescan.py
python/branches/py3k/Mac/Modules/mlte/mltesupport.py
python/branches/py3k/Mac/Modules/osa/osascan.py
python/branches/py3k/Mac/Modules/osa/osasupport.py
python/branches/py3k/Mac/Modules/qd/qdscan.py
python/branches/py3k/Mac/Modules/qd/qdsupport.py
python/branches/py3k/Mac/Modules/qdoffs/qdoffsscan.py
python/branches/py3k/Mac/Modules/qdoffs/qdoffssupport.py
python/branches/py3k/Mac/Modules/qt/qtscan.py
python/branches/py3k/Mac/Modules/qt/qtsupport.py
python/branches/py3k/Mac/Modules/res/resscan.py
python/branches/py3k/Mac/Modules/res/ressupport.py
python/branches/py3k/Mac/Modules/scrap/scrapscan.py
python/branches/py3k/Mac/Modules/scrap/scrapsupport.py
python/branches/py3k/Mac/Modules/snd/sndscan.py
python/branches/py3k/Mac/Modules/snd/sndsupport.py
python/branches/py3k/Mac/Modules/te/tescan.py
python/branches/py3k/Mac/Modules/te/tesupport.py
python/branches/py3k/Mac/Modules/win/winscan.py
python/branches/py3k/Mac/Modules/win/winsupport.py
python/branches/py3k/Misc/NEWS
python/branches/py3k/Misc/Vim/python.vim
python/branches/py3k/Misc/cheatsheet
python/branches/py3k/Misc/python-mode.el
python/branches/py3k/Objects/fileobject.c
python/branches/py3k/Python/bltinmodule.c
python/branches/py3k/README
python/branches/py3k/Tools/scripts/hotshotmain.py
python/branches/py3k/Tools/versioncheck/README
python/branches/py3k/Tools/versioncheck/checkversions.py
python/branches/py3k/setup.py
Log:
Kill execfile(), use exec() instead
Modified: python/branches/py3k/Demo/scripts/newslist.py
==============================================================================
--- python/branches/py3k/Demo/scripts/newslist.py (original)
+++ python/branches/py3k/Demo/scripts/newslist.py Sun Aug 12 02:43:29 2007
@@ -99,7 +99,7 @@
rcfile = os.path.join(dir, '.newslistrc.py')
if os.path.exists(rcfile):
print(rcfile)
- execfile(rcfile)
+ exec(open(rcfile).read())
break
from nntplib import NNTP
Modified: python/branches/py3k/Demo/scripts/pp.py
==============================================================================
--- python/branches/py3k/Demo/scripts/pp.py (original)
+++ python/branches/py3k/Demo/scripts/pp.py Sun Aug 12 02:43:29 2007
@@ -123,8 +123,9 @@
fp = tempfile.NamedTemporaryFile()
fp.write(program)
fp.flush()
+script = open(tfn).read()
if DFLAG:
import pdb
- pdb.run('execfile(%r)' % (tfn,))
+ pdb.run(script)
else:
- execfile(tfn)
+ exec(script)
Modified: python/branches/py3k/Doc/dist/dist.tex
==============================================================================
--- python/branches/py3k/Doc/dist/dist.tex (original)
+++ python/branches/py3k/Doc/dist/dist.tex Sun Aug 12 02:43:29 2007
@@ -2290,7 +2290,7 @@
(passed as keyword args from \var{script} to \function{setup()}), or
the contents of the config files or command-line.
-\var{script_name} is a file that will be run with \function{execfile()}
+\var{script_name} is a file that will be read and run with \function{exec()}
\code{sys.argv[0]} will be replaced with \var{script} for the duration of the
call. \var{script_args} is a list of strings; if supplied,
\code{sys.argv[1:]} will be replaced by \var{script_args} for the duration
Modified: python/branches/py3k/Doc/howto/doanddont.tex
==============================================================================
--- python/branches/py3k/Doc/howto/doanddont.tex (original)
+++ python/branches/py3k/Doc/howto/doanddont.tex Sun Aug 12 02:43:29 2007
@@ -81,7 +81,7 @@
\end{itemize}
-\subsection{Unadorned \function{exec}, \function{execfile} and friends}
+\subsection{Unadorned \function{exec} and friends}
The word ``unadorned'' refers to the use without an explicit dictionary,
in which case those constructs evaluate code in the {\em current} environment.
@@ -97,7 +97,7 @@
>>> def func(s, **kw):
>>> for var, val in kw.items():
>>> exec("s.%s=val" % var) # invalid!
->>> execfile("handler.py")
+>>> exec(open("handler.py").read())
>>> handle()
\end{verbatim}
@@ -111,7 +111,7 @@
>>> for var, val in kw.items():
>>> setattr(s, var, val)
>>> d={}
->>> execfile("handle.py", d, d)
+>>> exec(open("handler.py").read(), d, d)
>>> handle = d['handle']
>>> handle()
\end{verbatim}
Modified: python/branches/py3k/Doc/lib/libdoctest.tex
==============================================================================
--- python/branches/py3k/Doc/lib/libdoctest.tex (original)
+++ python/branches/py3k/Doc/lib/libdoctest.tex Sun Aug 12 02:43:29 2007
@@ -1828,7 +1828,7 @@
via \function{\refmodule{pdb}.post_mortem()}, passing the traceback object
from the unhandled exception. If \var{pm} is not specified, or is false,
the script is run under the debugger from the start, via passing an
- appropriate \function{execfile()} call to \function{\refmodule{pdb}.run()}.
+ appropriate \function{exec()} call to \function{\refmodule{pdb}.run()}.
\versionadded{2.3}
Modified: python/branches/py3k/Doc/lib/libexcs.tex
==============================================================================
--- python/branches/py3k/Doc/lib/libexcs.tex (original)
+++ python/branches/py3k/Doc/lib/libexcs.tex Sun Aug 12 02:43:29 2007
@@ -260,7 +260,7 @@
% XXXJH xref to these functions?
Raised when the parser encounters a syntax error. This may occur in
an \keyword{import} statement, in a call to the built-in functions
- \function{exec()}, \function{execfile()}, \function{eval()} or
+ \function{exec()}, \function{eval()} or
\function{input()}, or when reading the initial script or standard
input (also interactively).
Modified: python/branches/py3k/Doc/lib/libfuncs.tex
==============================================================================
--- python/branches/py3k/Doc/lib/libfuncs.tex (original)
+++ python/branches/py3k/Doc/lib/libfuncs.tex Sun Aug 12 02:43:29 2007
@@ -382,15 +382,13 @@
compiled passing \code{'eval'} as the \var{kind} argument.
Hints: dynamic execution of statements is supported by the
- \function{exec()} function. Execution of statements from a file is
- supported by the \function{execfile()} function. The
+ \function{exec()} function. The
\function{globals()} and \function{locals()} functions returns the
current global and local dictionary, respectively, which may be
useful to pass around for use by \function{eval()} or
- \function{execfile()}.
+ \function{exec()}.
\end{funcdesc}
-
\begin{funcdesc}{exec}{object\optional{, globals\optional{, locals}}}
This function supports dynamic execution of Python code.
\var{object} must be either a string, an open file object, or
@@ -425,31 +423,6 @@
argument to \function{exec()}.}
\end{funcdesc}
-\begin{funcdesc}{execfile}{filename\optional{, globals\optional{, locals}}}
- This function is similar to the \function{exec()} function, but parses a
- file given by the file name instead of a string. It
- is different from the \keyword{import} statement in that it does not
- use the module administration --- it reads the file unconditionally
- and does not create a new module.
-
- The arguments are a file name and two optional dictionaries. The file is
- parsed and evaluated as a sequence of Python statements (similarly to a
- module) using the \var{globals} and \var{locals} dictionaries as global and
- local namespace. If provided, \var{locals} can be any mapping object.
- \versionchanged[formerly \var{locals} was required to be a dictionary]{2.4}
- If the \var{locals} dictionary is omitted it defaults to the \var{globals}
- dictionary. If both dictionaries are omitted, the expression is executed in
- the environment where \function{execfile()} is called. The return value is
- \code{None}.
-
- \warning{The default \var{locals} act as described for function
- \function{locals()} below: modifications to the default \var{locals}
- dictionary should not be attempted. Pass an explicit \var{locals}
- dictionary if you need to see effects of the code on \var{locals} after
- function \function{execfile()} returns. \function{execfile()} cannot
- be used reliably to modify a function's locals.}
-\end{funcdesc}
-
\begin{funcdesc}{file}{filename\optional{, mode\optional{, bufsize}}}
Constructor function for the \class{file} type, described further
in section~\ref{bltin-file-objects}, ``\ulink{File
Modified: python/branches/py3k/Doc/lib/libuser.tex
==============================================================================
--- python/branches/py3k/Doc/lib/libuser.tex (original)
+++ python/branches/py3k/Doc/lib/libuser.tex Sun Aug 12 02:43:29 2007
@@ -24,7 +24,7 @@
The \module{user} module looks for a file \file{.pythonrc.py} in the user's
home directory and if it can be opened, executes it (using
-\function{execfile()}\bifuncindex{execfile}) in its own (the
+\function{exec()}\bifuncindex{exec}) in its own (the
module \module{user}'s) global namespace. Errors during this phase
are not caught; that's up to the program that imports the
\module{user} module, if it wishes. The home directory is assumed to
Modified: python/branches/py3k/Doc/ref/ref4.tex
==============================================================================
--- python/branches/py3k/Doc/ref/ref4.tex (original)
+++ python/branches/py3k/Doc/ref/ref4.tex Sun Aug 12 02:43:29 2007
@@ -19,8 +19,7 @@
interpreter or specified on the interpreter command line the first
argument) is a code block. A script command (a command specified on
the interpreter command line with the `\strong{-c}' option) is a code
-block. The file read by the built-in function \function{execfile()}
-is a code block. The string argument passed to the built-in functions
+block. The string argument passed to the built-in functions
\function{eval()} and \function{exec()} is a code block.
The expression read and evaluated by the built-in function
\function{input()} is a code block.
@@ -139,7 +138,7 @@
function and the function contains or is a nested block with free
variables, the compiler will raise a \exception{SyntaxError}.
-The \function{eval()}, \function{exec()}, \function{execfile()},
+The \function{eval()}, \function{exec()},
and \function{input()} functions do not have access to the
full environment for resolving names. Names may be resolved in the
local and global namespaces of the caller. Free variables are not
@@ -147,7 +146,7 @@
namespace.\footnote{This limitation occurs because the code that is
executed by these operations is not available at the time the
module is compiled.}
-The \function{exec()}, \function{eval()} and \function{execfile()}
+The \function{exec()} and \function{eval()}
functions have optional arguments to override
the global and local namespace. If only one namespace is specified,
it is used for both.
Modified: python/branches/py3k/Doc/ref/ref6.tex
==============================================================================
--- python/branches/py3k/Doc/ref/ref6.tex (original)
+++ python/branches/py3k/Doc/ref/ref6.tex Sun Aug 12 02:43:29 2007
@@ -760,8 +760,8 @@
That is not a future statement; it's an ordinary import statement with
no special semantics or syntax restrictions.
-Code compiled by calls to the builtin functions \function{exec()},
-\function{compile()} and \function{execfile()} that occur in a module
+Code compiled by calls to the builtin functions \function{exec()} and
+\function{compile()} that occur in a module
\module{M} containing a future statement will, by default, use the new
syntax or semantics associated with the future statement. This can,
starting with Python 2.2 be controlled by optional arguments to
@@ -811,9 +811,8 @@
does not affect the code block \emph{containing} the function call,
and code contained in such a string is unaffected by \keyword{global}
statements in the code containing the function call. The same applies to the
-\function{eval()}, \function{execfile()} and \function{compile()} functions.
+\function{eval()} and \function{compile()} functions.
\bifuncindex{exec}
\bifuncindex{eval}
-\bifuncindex{execfile}
\bifuncindex{compile}
Modified: python/branches/py3k/Doc/tut/tut.tex
==============================================================================
--- python/branches/py3k/Doc/tut/tut.tex (original)
+++ python/branches/py3k/Doc/tut/tut.tex Sun Aug 12 02:43:29 2007
@@ -409,14 +409,14 @@
If you want to read an additional start-up file from the current
directory, you can program this in the global start-up file using code
like \samp{if os.path.isfile('.pythonrc.py'):
-execfile('.pythonrc.py')}. If you want to use the startup file in a
+exec(open('.pythonrc.py')).read()}. If you want to use the startup file in a
script, you must do this explicitly in the script:
\begin{verbatim}
import os
filename = os.environ.get('PYTHONSTARTUP')
if filename and os.path.isfile(filename):
- execfile(filename)
+ exec(open(filename).read())
\end{verbatim}
@@ -2736,14 +2736,14 @@
'__name__', 'abs', 'basestring', 'bool', 'buffer',
'chr', 'classmethod', 'cmp', 'compile',
'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod',
- 'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', 'float',
+ 'enumerate', 'eval', 'exec', 'exit', 'filter', 'float',
'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex',
'id', 'input', 'int', 'isinstance', 'issubclass', 'iter',
- 'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'min',
+ 'len', 'license', 'list', 'locals', 'map', 'max', 'min',
'object', 'oct', 'open', 'ord', 'pow', 'property', 'quit', 'range',
'repr', 'reversed', 'round', 'set',
'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super',
- 'tuple', 'type', 'unichr', 'unicode', 'vars', 'zip']
+ 'tuple', 'type', 'vars', 'zip']
\end{verbatim}
@@ -4413,8 +4413,8 @@
(Buglet: derivation of a class with the same name as the base class
makes use of private variables of the base class possible.)
-Notice that code passed to \code{exec()}, \code{eval()} or
-\code{execfile()} does not consider the classname of the invoking
+Notice that code passed to \code{exec()} or \code{eval()}
+does not consider the classname of the invoking
class to be the current class; this is similar to the effect of the
\code{global} statement, the effect of which is likewise restricted to
code that is byte-compiled together. The same restriction applies to
Modified: python/branches/py3k/Lib/CGIHTTPServer.py
==============================================================================
--- python/branches/py3k/Lib/CGIHTTPServer.py (original)
+++ python/branches/py3k/Lib/CGIHTTPServer.py Sun Aug 12 02:43:29 2007
@@ -316,7 +316,7 @@
sys.argv.append(decoded_query)
sys.stdout = self.wfile
sys.stdin = self.rfile
- execfile(scriptfile, {"__name__": "__main__"})
+ exec(open(scriptfile).read(), {"__name__": "__main__"})
finally:
sys.argv = save_argv
sys.stdin = save_stdin
Modified: python/branches/py3k/Lib/cProfile.py
==============================================================================
--- python/branches/py3k/Lib/cProfile.py (original)
+++ python/branches/py3k/Lib/cProfile.py Sun Aug 12 02:43:29 2007
@@ -180,7 +180,12 @@
if (len(sys.argv) > 0):
sys.path.insert(0, os.path.dirname(sys.argv[0]))
- run('execfile(%r)' % (sys.argv[0],), options.outfile, options.sort)
+ fp = open(sys.argv[0])
+ try:
+ script = fp.read()
+ finally:
+ fp.close()
+ run('exec(%r)' % script, options.outfile, options.sort)
else:
parser.print_usage()
return parser
Modified: python/branches/py3k/Lib/distutils/core.py
==============================================================================
--- python/branches/py3k/Lib/distutils/core.py (original)
+++ python/branches/py3k/Lib/distutils/core.py Sun Aug 12 02:43:29 2007
@@ -179,7 +179,7 @@
keyword args from 'script' to 'setup()', or the contents of the
config files or command-line.
- 'script_name' is a file that will be run with 'execfile()';
+ 'script_name' is a file that will be read and run with 'exec()';
'sys.argv[0]' will be replaced with 'script' for the duration of the
call. 'script_args' is a list of strings; if supplied,
'sys.argv[1:]' will be replaced by 'script_args' for the duration of
@@ -217,7 +217,7 @@
sys.argv[0] = script_name
if script_args is not None:
sys.argv[1:] = script_args
- execfile(script_name, g, l)
+ exec(open(script_name).read(), g, l)
finally:
sys.argv = save_argv
_setup_stop_after = None
Modified: python/branches/py3k/Lib/doctest.py
==============================================================================
--- python/branches/py3k/Lib/doctest.py (original)
+++ python/branches/py3k/Lib/doctest.py Sun Aug 12 02:43:29 2007
@@ -2490,7 +2490,7 @@
# Note that tempfile.NameTemporaryFile() cannot be used. As the
# docs say, a file so created cannot be opened by name a second time
- # on modern Windows boxes, and execfile() needs to open it.
+ # on modern Windows boxes, and exec() needs to open and read it.
srcfilename = tempfile.mktemp(".py", "doctestdebug")
f = open(srcfilename, 'w')
f.write(src)
@@ -2504,14 +2504,17 @@
if pm:
try:
- execfile(srcfilename, globs, globs)
+ exec(open(srcfilename).read(), globs, globs)
except:
print(sys.exc_info()[1])
pdb.post_mortem(sys.exc_info()[2])
else:
- # Note that %r is vital here. '%s' instead can, e.g., cause
- # backslashes to get treated as metacharacters on Windows.
- pdb.run("execfile(%r)" % srcfilename, globs, globs)
+ fp = open(srcfilename)
+ try:
+ script = fp.read()
+ finally:
+ fp.close()
+ pdb.run("exec(%r)" % script, globs, globs)
finally:
os.remove(srcfilename)
Modified: python/branches/py3k/Lib/lib-tk/Tkinter.py
==============================================================================
--- python/branches/py3k/Lib/lib-tk/Tkinter.py (original)
+++ python/branches/py3k/Lib/lib-tk/Tkinter.py Sun Aug 12 02:43:29 2007
@@ -1688,8 +1688,8 @@
_default_root = None
def readprofile(self, baseName, className):
"""Internal function. It reads BASENAME.tcl and CLASSNAME.tcl into
- the Tcl Interpreter and calls execfile on BASENAME.py and CLASSNAME.py if
- such a file exists in the home directory."""
+ the Tcl Interpreter and calls exec on the contents of BASENAME.py and
+ CLASSNAME.py if such a file exists in the home directory."""
import os
if 'HOME' in os.environ: home = os.environ['HOME']
else: home = os.curdir
@@ -1702,11 +1702,11 @@
if os.path.isfile(class_tcl):
self.tk.call('source', class_tcl)
if os.path.isfile(class_py):
- execfile(class_py, dir)
+ exec(open(class_py).read(), dir)
if os.path.isfile(base_tcl):
self.tk.call('source', base_tcl)
if os.path.isfile(base_py):
- execfile(base_py, dir)
+ exec(open(base_py).read(), dir)
def report_callback_exception(self, exc, val, tb):
"""Internal function. It reports exception on sys.stderr."""
import traceback, sys
Modified: python/branches/py3k/Lib/optparse.py
==============================================================================
--- python/branches/py3k/Lib/optparse.py (original)
+++ python/branches/py3k/Lib/optparse.py Sun Aug 12 02:43:29 2007
@@ -874,7 +874,7 @@
def read_file(self, filename, mode="careful"):
vars = {}
- execfile(filename, vars)
+ exec(open(filename).read(), vars)
self._update(vars, mode)
def ensure_value(self, attr, value):
Modified: python/branches/py3k/Lib/pdb.py
==============================================================================
--- python/branches/py3k/Lib/pdb.py (original)
+++ python/branches/py3k/Lib/pdb.py Sun Aug 12 02:43:29 2007
@@ -1164,7 +1164,12 @@
self._wait_for_mainpyfile = 1
self.mainpyfile = self.canonic(filename)
self._user_requested_quit = 0
- statement = 'execfile( "%s")' % filename
+ fp = open(filename)
+ try:
+ script = fp.read()
+ finally:
+ fp.close()
+ statement = 'exec("%s")' % script
self.run(statement)
# Simplified interface
Modified: python/branches/py3k/Lib/plat-mac/appletrawmain.py
==============================================================================
--- python/branches/py3k/Lib/plat-mac/appletrawmain.py (original)
+++ python/branches/py3k/Lib/plat-mac/appletrawmain.py Sun Aug 12 02:43:29 2007
@@ -41,7 +41,7 @@
#
sys.argv[0] = __file__
del argvemulator, os, sys, _dir
- execfile(__file__)
+ exec(open(__file__).read())
else:
__file__ = os.path.join(_dir, '__main__.pyc')
if os.path.exists(__file__):
Modified: python/branches/py3k/Lib/plat-mac/bundlebuilder.py
==============================================================================
--- python/branches/py3k/Lib/plat-mac/bundlebuilder.py (original)
+++ python/branches/py3k/Lib/plat-mac/bundlebuilder.py Sun Aug 12 02:43:29 2007
@@ -322,7 +322,12 @@
import argvemulator, os
argvemulator.ArgvCollector().mainloop()
-execfile(os.path.join(os.path.split(__file__)[0], "%(realmainprogram)s"))
+fp = os.path.join(os.path.split(__file__)[0], "%(realmainprogram)s")
+try:
+ script = fp.read()
+finally:
+ fp.close()
+exec(script)
"""
#
Modified: python/branches/py3k/Lib/profile.py
==============================================================================
--- python/branches/py3k/Lib/profile.py (original)
+++ python/branches/py3k/Lib/profile.py Sun Aug 12 02:43:29 2007
@@ -609,7 +609,12 @@
if (len(sys.argv) > 0):
sys.path.insert(0, os.path.dirname(sys.argv[0]))
- run('execfile(%r)' % (sys.argv[0],), options.outfile, options.sort)
+ fp = open(sys.argv[0])
+ try:
+ script = fp.read()
+ finally:
+ fp.close()
+ run('exec(%r)' % script, options.outfile, options.sort)
else:
parser.print_usage()
return parser
Modified: python/branches/py3k/Lib/test/test_builtin.py
==============================================================================
--- python/branches/py3k/Lib/test/test_builtin.py (original)
+++ python/branches/py3k/Lib/test/test_builtin.py Sun Aug 12 02:43:29 2007
@@ -11,10 +11,6 @@
warnings.filterwarnings("ignore", "integer argument expected",
DeprecationWarning, "unittest")
-# count the number of test runs.
-# used to skip running test_execfile() multiple times
-numruns = 0
-
class Squares:
def __init__(self, max):
@@ -399,57 +395,6 @@
return 1 # used to be 'a' but that's no longer an error
self.assertRaises(TypeError, eval, 'dir()', globals(), C())
- # Done outside of the method test_z to get the correct scope
- z = 0
- f = open(TESTFN, 'w')
- f.write('z = z+1\n')
- f.write('z = z*2\n')
- f.close()
- execfile(TESTFN)
-
- def test_execfile(self):
- global numruns
- if numruns:
- return
- numruns += 1
-
- globals = {'a': 1, 'b': 2}
- locals = {'b': 200, 'c': 300}
-
- self.assertEqual(self.__class__.z, 2)
- globals['z'] = 0
- execfile(TESTFN, globals)
- self.assertEqual(globals['z'], 2)
- locals['z'] = 0
- execfile(TESTFN, globals, locals)
- self.assertEqual(locals['z'], 2)
-
- class M:
- "Test mapping interface versus possible calls from execfile()."
- def __init__(self):
- self.z = 10
- def __getitem__(self, key):
- if key == 'z':
- return self.z
- raise KeyError
- def __setitem__(self, key, value):
- if key == 'z':
- self.z = value
- return
- raise KeyError
-
- locals = M()
- locals['z'] = 0
- execfile(TESTFN, globals, locals)
- self.assertEqual(locals['z'], 2)
-
- unlink(TESTFN)
- self.assertRaises(TypeError, execfile)
- self.assertRaises(TypeError, execfile, TESTFN, {}, ())
- import os
- self.assertRaises(IOError, execfile, os.curdir)
- self.assertRaises(IOError, execfile, "I_dont_exist")
-
def test_exec(self):
g = {}
exec('z = 1', g)
Modified: python/branches/py3k/Lib/test/test_multibytecodec.py
==============================================================================
--- python/branches/py3k/Lib/test/test_multibytecodec.py (original)
+++ python/branches/py3k/Lib/test/test_multibytecodec.py Sun Aug 12 02:43:29 2007
@@ -49,7 +49,7 @@
try:
for enc in ALL_CJKENCODINGS:
print('# coding:', enc, file=io.open(TESTFN, 'w'))
- execfile(TESTFN)
+ exec(open(TESTFN).read())
finally:
test_support.unlink(TESTFN)
Modified: python/branches/py3k/Lib/test/test_pkg.py
==============================================================================
--- python/branches/py3k/Lib/test/test_pkg.py (original)
+++ python/branches/py3k/Lib/test/test_pkg.py Sun Aug 12 02:43:29 2007
@@ -63,7 +63,7 @@
sys.path.insert(0, root)
if verbose: print("sys.path =", sys.path)
try:
- execfile(fname, globals(), {})
+ exec(open(fname).read(), globals(), {})
except:
traceback.print_exc(file=sys.stdout)
finally:
Modified: python/branches/py3k/Lib/test/test_univnewlines.py
==============================================================================
--- python/branches/py3k/Lib/test/test_univnewlines.py (original)
+++ python/branches/py3k/Lib/test/test_univnewlines.py Sun Aug 12 02:43:29 2007
@@ -78,13 +78,6 @@
data = fp.readlines()
self.assertEqual(data, DATA_SPLIT[1:])
- def test_execfile(self):
- namespace = {}
- execfile(test_support.TESTFN, namespace)
- func = namespace['line3']
- self.assertEqual(func.__code__.co_firstlineno, 3)
- self.assertEqual(namespace['line4'], FATX)
-
class TestNativeNewlines(TestGenericUnivNewlines):
NEWLINE = None
Modified: python/branches/py3k/Lib/trace.py
==============================================================================
--- python/branches/py3k/Lib/trace.py (original)
+++ python/branches/py3k/Lib/trace.py Sun Aug 12 02:43:29 2007
@@ -773,7 +773,12 @@
ignoredirs=ignore_dirs, infile=counts_file,
outfile=counts_file)
try:
- t.run('execfile(%r)' % (progname,))
+ fp = open(progname)
+ try:
+ script = fp.read()
+ finally:
+ fp.close()
+ t.run('exec(%r)' % (script,))
except IOError as err:
_err_exit("Cannot run file %r because: %s" % (sys.argv[0], err))
except SystemExit:
Modified: python/branches/py3k/Lib/user.py
==============================================================================
--- python/branches/py3k/Lib/user.py (original)
+++ python/branches/py3k/Lib/user.py Sun Aug 12 02:43:29 2007
@@ -12,7 +12,7 @@
import user
The user module looks for a file .pythonrc.py in the user's home
-directory and if it can be opened, execfile()s it in its own global
+directory and if it can be opened and read, exec()s it in its own global
namespace. Errors during this phase are not caught; that's up to the
program that imports the user module, if it wishes.
@@ -42,4 +42,4 @@
pass
else:
f.close()
- execfile(pythonrc)
+ exec(open(pythonrc).read())
Modified: python/branches/py3k/Mac/Modules/ae/aescan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/ae/aescan.py (original)
+++ python/branches/py3k/Mac/Modules/ae/aescan.py Sun Aug 12 02:43:29 2007
@@ -21,7 +21,7 @@
scanner.scan()
scanner.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done Scanning and Generating, now doing 'import aesupport' ==="
import aesupport
print "=== Done 'import aesupport'. It's up to you to compile AEmodule.c ==="
Modified: python/branches/py3k/Mac/Modules/ae/aesupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/ae/aesupport.py (original)
+++ python/branches/py3k/Mac/Modules/ae/aesupport.py Sun Aug 12 02:43:29 2007
@@ -213,8 +213,8 @@
functions = []
aedescmethods = []
-execfile('aegen.py')
-##execfile('aedatamodelgen.py')
+exec(open('aegen.py').read())
+##exec(open('aedatamodelgen.py').read())
# Manual generator
AutoDispose_body = """
Modified: python/branches/py3k/Mac/Modules/ah/ahscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/ah/ahscan.py (original)
+++ python/branches/py3k/Mac/Modules/ah/ahscan.py Sun Aug 12 02:43:29 2007
@@ -18,7 +18,7 @@
scanner.scan()
scanner.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ==="
exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ==="
Modified: python/branches/py3k/Mac/Modules/ah/ahsupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/ah/ahsupport.py (original)
+++ python/branches/py3k/Mac/Modules/ah/ahsupport.py Sun Aug 12 02:43:29 2007
@@ -34,7 +34,7 @@
# Create and populate the lists
functions = []
-execfile(INPUTFILE)
+exec(open(INPUTFILE).read())
# add the populated lists to the generator groups
# (in a different wordl the scan program would generate this)
Modified: python/branches/py3k/Mac/Modules/app/appscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/app/appscan.py (original)
+++ python/branches/py3k/Mac/Modules/app/appscan.py Sun Aug 12 02:43:29 2007
@@ -18,7 +18,7 @@
scanner.scan()
scanner.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ==="
exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ==="
Modified: python/branches/py3k/Mac/Modules/app/appsupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/app/appsupport.py (original)
+++ python/branches/py3k/Mac/Modules/app/appsupport.py Sun Aug 12 02:43:29 2007
@@ -121,7 +121,7 @@
# Create and populate the lists
functions = []
methods = []
-execfile(INPUTFILE)
+exec(open(INPUTFILE).read())
# add the populated lists to the generator groups
# (in a different wordl the scan program would generate this)
Modified: python/branches/py3k/Mac/Modules/carbonevt/CarbonEvtscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/carbonevt/CarbonEvtscan.py (original)
+++ python/branches/py3k/Mac/Modules/carbonevt/CarbonEvtscan.py Sun Aug 12 02:43:29 2007
@@ -20,7 +20,7 @@
scanner.scan()
scanner.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "--done scanning, importing--"
import CarbonEvtsupport
print "done"
Modified: python/branches/py3k/Mac/Modules/carbonevt/CarbonEvtsupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/carbonevt/CarbonEvtsupport.py (original)
+++ python/branches/py3k/Mac/Modules/carbonevt/CarbonEvtsupport.py Sun Aug 12 02:43:29 2007
@@ -214,7 +214,7 @@
execstr = typ + 'methods = []'
exec execstr
-execfile('CarbonEventsgen.py')
+exec(open('CarbonEventsgen.py').read())
Modified: python/branches/py3k/Mac/Modules/cf/cfscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/cf/cfscan.py (original)
+++ python/branches/py3k/Mac/Modules/cf/cfscan.py Sun Aug 12 02:43:29 2007
@@ -45,7 +45,7 @@
scanner.gentypetest(SHORT+"typetest.py")
scanner.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ==="
exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ==="
Modified: python/branches/py3k/Mac/Modules/cf/cfsupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/cf/cfsupport.py (original)
+++ python/branches/py3k/Mac/Modules/cf/cfsupport.py Sun Aug 12 02:43:29 2007
@@ -529,7 +529,7 @@
CFURLRef_methods = []
# ADD _methods initializer here
-execfile(INPUTFILE)
+exec(open(INPUTFILE).read())
# add the populated lists to the generator groups
Modified: python/branches/py3k/Mac/Modules/cg/cgscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/cg/cgscan.py (original)
+++ python/branches/py3k/Mac/Modules/cg/cgscan.py Sun Aug 12 02:43:29 2007
@@ -23,7 +23,7 @@
scanner.gentypetest(SHORT+"typetest.py")
scanner.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ==="
exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ==="
Modified: python/branches/py3k/Mac/Modules/cg/cgsupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/cg/cgsupport.py (original)
+++ python/branches/py3k/Mac/Modules/cg/cgsupport.py Sun Aug 12 02:43:29 2007
@@ -145,7 +145,7 @@
CGContextRef_methods = []
# ADD _methods initializer here
-execfile(INPUTFILE)
+exec(open(INPUTFILE).read())
# manual method, lives in Quickdraw.h
f = Method(void, 'SyncCGContextOriginWithPort',
Modified: python/branches/py3k/Mac/Modules/cm/cmscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/cm/cmscan.py (original)
+++ python/branches/py3k/Mac/Modules/cm/cmscan.py Sun Aug 12 02:43:29 2007
@@ -17,7 +17,7 @@
scanner.scan()
scanner.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ==="
exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ==="
Modified: python/branches/py3k/Mac/Modules/cm/cmsupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/cm/cmsupport.py (original)
+++ python/branches/py3k/Mac/Modules/cm/cmsupport.py Sun Aug 12 02:43:29 2007
@@ -112,7 +112,7 @@
functions = []
c_methods = []
ci_methods = []
-execfile(INPUTFILE)
+exec(open(INPUTFILE).read())
# add the populated lists to the generator groups
# (in a different wordl the scan program would generate this)
Modified: python/branches/py3k/Mac/Modules/ctl/ctlscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/ctl/ctlscan.py (original)
+++ python/branches/py3k/Mac/Modules/ctl/ctlscan.py Sun Aug 12 02:43:29 2007
@@ -15,7 +15,7 @@
scanner.scan()
scanner.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now doing 'import ctlsupport' ==="
import ctlsupport
print "=== Done. It's up to you to compile Ctlmodule.c ==="
Modified: python/branches/py3k/Mac/Modules/ctl/ctlsupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/ctl/ctlsupport.py (original)
+++ python/branches/py3k/Mac/Modules/ctl/ctlsupport.py Sun Aug 12 02:43:29 2007
@@ -507,8 +507,8 @@
# Create and populate the lists
functions = []
methods = []
-execfile(INPUTFILE)
-execfile('ctledit.py')
+exec(open(INPUTFILE).read())
+exec(open('ctledit.py').read())
# add the populated lists to the generator groups
for f in functions: module.add(f)
Modified: python/branches/py3k/Mac/Modules/dlg/dlgscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/dlg/dlgscan.py (original)
+++ python/branches/py3k/Mac/Modules/dlg/dlgscan.py Sun Aug 12 02:43:29 2007
@@ -19,7 +19,7 @@
scanner.scan()
scanner.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ==="
exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ==="
Modified: python/branches/py3k/Mac/Modules/dlg/dlgsupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/dlg/dlgsupport.py (original)
+++ python/branches/py3k/Mac/Modules/dlg/dlgsupport.py Sun Aug 12 02:43:29 2007
@@ -240,7 +240,7 @@
# Create and populate the lists
functions = []
methods = []
-execfile("dlggen.py")
+exec(open("dlggen.py").read())
# add the populated lists to the generator groups
for f in functions: module.add(f)
Modified: python/branches/py3k/Mac/Modules/drag/dragscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/drag/dragscan.py (original)
+++ python/branches/py3k/Mac/Modules/drag/dragscan.py Sun Aug 12 02:43:29 2007
@@ -26,7 +26,7 @@
scanner.scan()
scanner.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now doing 'import dragsupport' ==="
import dragsupport
print "=== Done. It's up to you to compile Dragmodule.c ==="
Modified: python/branches/py3k/Mac/Modules/drag/dragsupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/drag/dragsupport.py (original)
+++ python/branches/py3k/Mac/Modules/drag/dragsupport.py Sun Aug 12 02:43:29 2007
@@ -216,7 +216,7 @@
# Create and populate the lists
functions = []
methods = []
-execfile(INPUTFILE)
+exec(open(INPUTFILE).read())
# add the populated lists to the generator groups
for f in functions: module.add(f)
Modified: python/branches/py3k/Mac/Modules/evt/evtscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/evt/evtscan.py (original)
+++ python/branches/py3k/Mac/Modules/evt/evtscan.py Sun Aug 12 02:43:29 2007
@@ -18,7 +18,7 @@
scanner.scan()
scanner.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ==="
exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ==="
Modified: python/branches/py3k/Mac/Modules/evt/evtsupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/evt/evtsupport.py (original)
+++ python/branches/py3k/Mac/Modules/evt/evtsupport.py Sun Aug 12 02:43:29 2007
@@ -50,7 +50,7 @@
# Create and populate the lists
functions = []
-execfile(INPUTFILE)
+exec(open(INPUTFILE).read())
# Move TickCount here, for convenience
f = Function(UInt32, 'TickCount',
Modified: python/branches/py3k/Mac/Modules/file/filescan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/file/filescan.py (original)
+++ python/branches/py3k/Mac/Modules/file/filescan.py Sun Aug 12 02:43:29 2007
@@ -18,7 +18,7 @@
scanner.close()
scanner.gentypetest(SHORT+"typetest.py")
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ==="
exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ==="
Modified: python/branches/py3k/Mac/Modules/file/filesupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/file/filesupport.py (original)
+++ python/branches/py3k/Mac/Modules/file/filesupport.py Sun Aug 12 02:43:29 2007
@@ -340,7 +340,7 @@
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(FSRef, PyMac_GetFSRef);
"""
-execfile(string.lower(MODPREFIX) + 'typetest.py')
+exec(open(string.lower(MODPREFIX) + 'typetest.py').read())
# Our object types:
class FSCatalogInfoDefinition(PEP253Mixin, ObjectDefinition):
@@ -806,7 +806,7 @@
alias_methods = []
fsref_methods = []
fsspec_methods = []
-execfile(INPUTFILE)
+exec(open(INPUTFILE).read())
# Manual generators:
FSRefMakePath_body = """
Modified: python/branches/py3k/Mac/Modules/fm/fmscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/fm/fmscan.py (original)
+++ python/branches/py3k/Mac/Modules/fm/fmscan.py Sun Aug 12 02:43:29 2007
@@ -17,7 +17,7 @@
scanner.scan()
scanner.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ==="
exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ==="
Modified: python/branches/py3k/Mac/Modules/fm/fmsupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/fm/fmsupport.py (original)
+++ python/branches/py3k/Mac/Modules/fm/fmsupport.py Sun Aug 12 02:43:29 2007
@@ -70,7 +70,7 @@
# Create and populate the lists
functions = []
-execfile(INPUTFILE)
+exec(open(INPUTFILE).read())
# add the populated lists to the generator groups
# (in a different wordl the scan program would generate this)
Modified: python/branches/py3k/Mac/Modules/folder/folderscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/folder/folderscan.py (original)
+++ python/branches/py3k/Mac/Modules/folder/folderscan.py Sun Aug 12 02:43:29 2007
@@ -19,7 +19,7 @@
scanner.close()
scanner.gentypetest(SHORT+"typetest.py")
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ==="
exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ==="
Modified: python/branches/py3k/Mac/Modules/folder/foldersupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/folder/foldersupport.py (original)
+++ python/branches/py3k/Mac/Modules/folder/foldersupport.py Sun Aug 12 02:43:29 2007
@@ -33,7 +33,7 @@
"""
-execfile(string.lower(MODPREFIX) + 'typetest.py')
+exec(open(string.lower(MODPREFIX) + 'typetest.py').read())
# From here on it's basically all boiler plate...
@@ -45,7 +45,7 @@
# Create and populate the lists
functions = []
-execfile(INPUTFILE)
+exec(open(INPUTFILE).read())
# add the populated lists to the generator groups
# (in a different wordl the scan program would generate this)
Modified: python/branches/py3k/Mac/Modules/help/helpscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/help/helpscan.py (original)
+++ python/branches/py3k/Mac/Modules/help/helpscan.py Sun Aug 12 02:43:29 2007
@@ -18,7 +18,7 @@
scanner.scan()
scanner.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ==="
exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ==="
Modified: python/branches/py3k/Mac/Modules/help/helpsupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/help/helpsupport.py (original)
+++ python/branches/py3k/Mac/Modules/help/helpsupport.py Sun Aug 12 02:43:29 2007
@@ -66,7 +66,7 @@
# Create and populate the lists
functions = []
##methods = []
-execfile(INPUTFILE)
+exec(open(INPUTFILE).read())
# add the populated lists to the generator groups
# (in a different wordl the scan program would generate this)
Modified: python/branches/py3k/Mac/Modules/ibcarbon/IBCarbonscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/ibcarbon/IBCarbonscan.py (original)
+++ python/branches/py3k/Mac/Modules/ibcarbon/IBCarbonscan.py Sun Aug 12 02:43:29 2007
@@ -18,7 +18,7 @@
scanner.scan()
scanner.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "--done scanning, importing--"
import IBCarbonsupport
print "done"
Modified: python/branches/py3k/Mac/Modules/ibcarbon/IBCarbonsupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/ibcarbon/IBCarbonsupport.py (original)
+++ python/branches/py3k/Mac/Modules/ibcarbon/IBCarbonsupport.py Sun Aug 12 02:43:29 2007
@@ -42,7 +42,7 @@
functions = []
methods = []
-execfile('IBCarbongen.py')
+exec(open('IBCarbongen.py').read())
for f in functions: module.add(f)
for m in methods: ibnibobject.add(m)
Modified: python/branches/py3k/Mac/Modules/icn/icnscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/icn/icnscan.py (original)
+++ python/branches/py3k/Mac/Modules/icn/icnscan.py Sun Aug 12 02:43:29 2007
@@ -18,7 +18,7 @@
scanner.scan()
scanner.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ==="
exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ==="
Modified: python/branches/py3k/Mac/Modules/icn/icnsupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/icn/icnsupport.py (original)
+++ python/branches/py3k/Mac/Modules/icn/icnsupport.py Sun Aug 12 02:43:29 2007
@@ -78,7 +78,7 @@
# Create and populate the lists
functions = []
##methods = []
-execfile(INPUTFILE)
+exec(open(INPUTFILE).read())
# add the populated lists to the generator groups
# (in a different wordl the scan program would generate this)
Modified: python/branches/py3k/Mac/Modules/launch/launchscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/launch/launchscan.py (original)
+++ python/branches/py3k/Mac/Modules/launch/launchscan.py Sun Aug 12 02:43:29 2007
@@ -19,7 +19,7 @@
scanner.close()
scanner.gentypetest(SHORT+"typetest.py")
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ==="
exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ==="
Modified: python/branches/py3k/Mac/Modules/launch/launchsupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/launch/launchsupport.py (original)
+++ python/branches/py3k/Mac/Modules/launch/launchsupport.py Sun Aug 12 02:43:29 2007
@@ -75,7 +75,7 @@
"""
# From here on it's basically all boiler plate...
-execfile(string.lower(MODPREFIX) + 'typetest.py')
+exec(open(string.lower(MODPREFIX) + 'typetest.py').read())
# Create the generator groups and link them
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
@@ -89,7 +89,7 @@
# Create and populate the lists
functions = []
##methods = []
-execfile(INPUTFILE)
+exec(open(INPUTFILE).read())
# add the populated lists to the generator groups
# (in a different wordl the scan program would generate this)
Modified: python/branches/py3k/Mac/Modules/list/listscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/list/listscan.py (original)
+++ python/branches/py3k/Mac/Modules/list/listscan.py Sun Aug 12 02:43:29 2007
@@ -18,7 +18,7 @@
scanner.scan()
scanner.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ==="
exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ==="
Modified: python/branches/py3k/Mac/Modules/list/listsupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/list/listsupport.py (original)
+++ python/branches/py3k/Mac/Modules/list/listsupport.py Sun Aug 12 02:43:29 2007
@@ -169,7 +169,7 @@
# Create and populate the lists
functions = []
methods = []
-execfile(INPUTFILE)
+exec(open(INPUTFILE).read())
# Function to convert any handle to a list and vv.
##f = Function(ListHandle, 'as_List', (Handle, 'h', InMode))
Modified: python/branches/py3k/Mac/Modules/menu/menuscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/menu/menuscan.py (original)
+++ python/branches/py3k/Mac/Modules/menu/menuscan.py Sun Aug 12 02:43:29 2007
@@ -14,7 +14,7 @@
scanner.scan()
scanner.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now doing 'import menusupport' ==="
import menusupport
print "=== Done. It's up to you to compile Menumodule.c ==="
Modified: python/branches/py3k/Mac/Modules/menu/menusupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/menu/menusupport.py (original)
+++ python/branches/py3k/Mac/Modules/menu/menusupport.py Sun Aug 12 02:43:29 2007
@@ -96,8 +96,8 @@
# Create and populate the lists
functions = []
methods = []
-execfile(INPUTFILE)
-execfile(EXTRAFILE)
+exec(open(INPUTFILE).read())
+exec(open(EXTRAFILE).read())
# add the populated lists to the generator groups
for f in functions: module.add(f)
Modified: python/branches/py3k/Mac/Modules/mlte/mltescan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/mlte/mltescan.py (original)
+++ python/branches/py3k/Mac/Modules/mlte/mltescan.py Sun Aug 12 02:43:29 2007
@@ -20,7 +20,7 @@
scanner.gentypetest(SHORT+"typetest.py")
scanner.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ==="
exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ==="
Modified: python/branches/py3k/Mac/Modules/mlte/mltesupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/mlte/mltesupport.py (original)
+++ python/branches/py3k/Mac/Modules/mlte/mltesupport.py Sun Aug 12 02:43:29 2007
@@ -128,7 +128,7 @@
UniChar = Type("UniChar", "h") # XXXX For now...
# ADD object type here
-execfile("mltetypetest.py")
+exec(open("mltetypetest.py").read())
# Our (opaque) objects
@@ -166,7 +166,7 @@
TXNFontMenuObject_methods = []
# ADD _methods initializer here
-execfile(INPUTFILE)
+exec(open(INPUTFILE).read())
# add the populated lists to the generator groups
Modified: python/branches/py3k/Mac/Modules/osa/osascan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/osa/osascan.py (original)
+++ python/branches/py3k/Mac/Modules/osa/osascan.py Sun Aug 12 02:43:29 2007
@@ -18,7 +18,7 @@
scanner.close()
scanner.gentypetest(SHORT+"typetest.py")
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ==="
exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ==="
Modified: python/branches/py3k/Mac/Modules/osa/osasupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/osa/osasupport.py (original)
+++ python/branches/py3k/Mac/Modules/osa/osasupport.py Sun Aug 12 02:43:29 2007
@@ -88,12 +88,12 @@
Method = OSErrWeakLinkMethodGenerator
# Test which types we are still missing.
-execfile(string.lower(MODPREFIX) + 'typetest.py')
+exec(open(string.lower(MODPREFIX) + 'typetest.py').read())
# Create and populate the lists
functions = []
methods = []
-execfile(INPUTFILE)
+exec(open(INPUTFILE).read())
# add the populated lists to the generator groups
# (in a different wordl the scan program would generate this)
Modified: python/branches/py3k/Mac/Modules/qd/qdscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/qd/qdscan.py (original)
+++ python/branches/py3k/Mac/Modules/qd/qdscan.py Sun Aug 12 02:43:29 2007
@@ -41,7 +41,7 @@
ofp.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ==="
import qdsupport
print "=== Done. It's up to you to compile it now! ==="
Modified: python/branches/py3k/Mac/Modules/qd/qdsupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/qd/qdsupport.py (original)
+++ python/branches/py3k/Mac/Modules/qd/qdsupport.py Sun Aug 12 02:43:29 2007
@@ -269,8 +269,8 @@
gr_methods = []
bm_methods = []
#methods = []
-execfile(INPUTFILE)
-execfile(EXTRAFILE)
+exec(open(INPUTFILE).read())
+exec(open(EXTRAFILE).read())
# add the populated lists to the generator groups
# (in a different wordl the scan program would generate this)
Modified: python/branches/py3k/Mac/Modules/qdoffs/qdoffsscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/qdoffs/qdoffsscan.py (original)
+++ python/branches/py3k/Mac/Modules/qdoffs/qdoffsscan.py Sun Aug 12 02:43:29 2007
@@ -14,7 +14,7 @@
scanner.scan()
scanner.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ==="
import qdoffssupport
print "=== Done. It's up to you to compile it now! ==="
Modified: python/branches/py3k/Mac/Modules/qdoffs/qdoffssupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/qdoffs/qdoffssupport.py (original)
+++ python/branches/py3k/Mac/Modules/qdoffs/qdoffssupport.py Sun Aug 12 02:43:29 2007
@@ -86,7 +86,7 @@
# Create and populate the lists
functions = []
methods = []
-execfile(INPUTFILE)
+exec(open(INPUTFILE).read())
# A method to convert a GWorldPtr to a GrafPtr
f = Method(GrafPtr, 'as_GrafPtr', (GWorldPtr, 'p', InMode))
Modified: python/branches/py3k/Mac/Modules/qt/qtscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/qt/qtscan.py (original)
+++ python/branches/py3k/Mac/Modules/qt/qtscan.py Sun Aug 12 02:43:29 2007
@@ -35,7 +35,7 @@
scanner.close()
scanner.gentypetest(SHORT+"typetest.py")
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ==="
exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ==="
Modified: python/branches/py3k/Mac/Modules/qt/qtsupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/qt/qtsupport.py (original)
+++ python/branches/py3k/Mac/Modules/qt/qtsupport.py Sun Aug 12 02:43:29 2007
@@ -307,7 +307,7 @@
module.addobject(SGOutput_object)
# Test which types we are still missing.
-execfile(string.lower(MODPREFIX) + 'typetest.py')
+exec(open(string.lower(MODPREFIX) + 'typetest.py').read())
# Create the generator classes used to populate the lists
Function = OSErrWeakLinkFunctionGenerator
@@ -323,7 +323,7 @@
Track_methods = []
Movie_methods = []
SGOutput_methods = []
-execfile(INPUTFILE)
+exec(open(INPUTFILE).read())
#
# Some functions from ImageCompression.h that we need:
Modified: python/branches/py3k/Mac/Modules/res/resscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/res/resscan.py (original)
+++ python/branches/py3k/Mac/Modules/res/resscan.py Sun Aug 12 02:43:29 2007
@@ -20,7 +20,7 @@
scanner.scan()
scanner.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now doing 'import ressupport' ==="
import ressupport
print "=== Done 'import ressupport'. It's up to you to compile Resmodule.c ==="
Modified: python/branches/py3k/Mac/Modules/res/ressupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/res/ressupport.py (original)
+++ python/branches/py3k/Mac/Modules/res/ressupport.py Sun Aug 12 02:43:29 2007
@@ -211,8 +211,8 @@
functions = []
resmethods = []
-execfile('resgen.py')
-execfile('resedit.py')
+exec(open('resgen.py').read())
+exec(open('resedit.py').read())
for f in functions: module.add(f)
for f in resmethods: resobject.add(f)
Modified: python/branches/py3k/Mac/Modules/scrap/scrapscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/scrap/scrapscan.py (original)
+++ python/branches/py3k/Mac/Modules/scrap/scrapscan.py Sun Aug 12 02:43:29 2007
@@ -20,7 +20,7 @@
scanner.scan()
scanner.close()
## print "=== Testing definitions output code ==="
-## execfile(defsoutput, {}, {})
+## exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ==="
exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ==="
Modified: python/branches/py3k/Mac/Modules/scrap/scrapsupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/scrap/scrapsupport.py (original)
+++ python/branches/py3k/Mac/Modules/scrap/scrapsupport.py Sun Aug 12 02:43:29 2007
@@ -63,7 +63,7 @@
# Create and populate the lists
functions = []
methods = []
-execfile(INPUTFILE)
+exec(open(INPUTFILE).read())
# add the populated lists to the generator groups
# (in a different wordl the scan program would generate this)
Modified: python/branches/py3k/Mac/Modules/snd/sndscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/snd/sndscan.py (original)
+++ python/branches/py3k/Mac/Modules/snd/sndscan.py Sun Aug 12 02:43:29 2007
@@ -17,7 +17,7 @@
scanner.scan()
scanner.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now doing 'import sndsupport' ==="
import sndsupport
print "=== Done. It's up to you to compile Sndmodule.c ==="
Modified: python/branches/py3k/Mac/Modules/snd/sndsupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/snd/sndsupport.py (original)
+++ python/branches/py3k/Mac/Modules/snd/sndsupport.py Sun Aug 12 02:43:29 2007
@@ -304,7 +304,7 @@
# populate the lists
-execfile('sndgen.py')
+exec(open('sndgen.py').read())
# add the functions and methods to the module and object, respectively
Modified: python/branches/py3k/Mac/Modules/te/tescan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/te/tescan.py (original)
+++ python/branches/py3k/Mac/Modules/te/tescan.py Sun Aug 12 02:43:29 2007
@@ -18,7 +18,7 @@
scanner.scan()
scanner.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ==="
exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ==="
Modified: python/branches/py3k/Mac/Modules/te/tesupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/te/tesupport.py (original)
+++ python/branches/py3k/Mac/Modules/te/tesupport.py Sun Aug 12 02:43:29 2007
@@ -198,7 +198,7 @@
# Create and populate the lists
functions = []
methods = []
-execfile(INPUTFILE)
+exec(open(INPUTFILE).read())
# Converter from/to handle
f = Function(TEHandle, 'as_TE', (Handle, 'h', InMode))
Modified: python/branches/py3k/Mac/Modules/win/winscan.py
==============================================================================
--- python/branches/py3k/Mac/Modules/win/winscan.py (original)
+++ python/branches/py3k/Mac/Modules/win/winscan.py Sun Aug 12 02:43:29 2007
@@ -14,7 +14,7 @@
scanner.scan()
scanner.close()
print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
+ exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ==="
import winsupport
print "=== Done. It's up to you to compile it now! ==="
Modified: python/branches/py3k/Mac/Modules/win/winsupport.py
==============================================================================
--- python/branches/py3k/Mac/Modules/win/winsupport.py (original)
+++ python/branches/py3k/Mac/Modules/win/winsupport.py Sun Aug 12 02:43:29 2007
@@ -191,7 +191,7 @@
# Create and populate the lists
functions = []
methods = []
-execfile(INPUTFILE)
+exec(open(INPUTFILE).read())
# Add manual routines for converting integer WindowPtr's (as returned by
# various event routines) and Dialog objects to a WindowObject.
@@ -211,8 +211,8 @@
# And add the routines that access the internal bits of a window struct. They
# are currently #defined in Windows.h, they will be real routines in Copland
-# (at which time this execfile can go)
-execfile(EDITFILE)
+# (at which time this exec can go)
+exec(open(EDITFILE).read())
# add the populated lists to the generator groups
# (in a different wordl the scan program would generate this)
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Sun Aug 12 02:43:29 2007
@@ -152,7 +152,7 @@
backticks (ie, `x`), <>
- Removed these Python builtins:
- apply(), callable(), coerce(), file(), reduce(), reload()
+ apply(), callable(), coerce(), execfile(), file(), reduce(), reload()
- Removed these Python methods:
{}.has_key
Modified: python/branches/py3k/Misc/Vim/python.vim
==============================================================================
--- python/branches/py3k/Misc/Vim/python.vim (original)
+++ python/branches/py3k/Misc/Vim/python.vim Sun Aug 12 02:43:29 2007
@@ -66,10 +66,10 @@
syn keyword pythonBuiltin __import__ abs all any basestring bool
syn keyword pythonBuiltin buffer callable chr classmethod cmp
syn keyword pythonBuiltin complex copyright credits delattr dict
- syn keyword pythonBuiltin dir divmod enumerate eval execfile exit file
+ syn keyword pythonBuiltin dir divmod enumerate eval exec exit
syn keyword pythonBuiltin filter float frozenset getattr globals hasattr
syn keyword pythonBuiltin hash help hex id int isinstance
- syn keyword pythonBuiltin issubclass iter len license list locals long map
+ syn keyword pythonBuiltin issubclass iter len license list locals map
syn keyword pythonBuiltin max min object oct open ord pow property quit
syn keyword pythonBuiltin range reload repr reversed round
syn keyword pythonBuiltin set setattr slice sorted staticmethod str sum
Modified: python/branches/py3k/Misc/cheatsheet
==============================================================================
--- python/branches/py3k/Misc/cheatsheet (original)
+++ python/branches/py3k/Misc/cheatsheet Sun Aug 12 02:43:29 2007
@@ -282,11 +282,10 @@
Numeric types
-Floats, integers and long integers.
+Floats and integers.
Floats are implemented with C doubles.
- Integers are implemented with C longs.
- Long integers have unlimited size (only limit is system resources)
+ Integers have unlimited size (only limit is system resources)
Operators on all numeric types
@@ -294,7 +293,6 @@
Operation Result
abs(x) the absolute value of x
int(x) x converted to integer
-long(x) x converted to long integer
float(x) x converted to floating point
-x x negated
+x x unchanged
@@ -306,7 +304,7 @@
divmod(x, y) the tuple (x/y, x%y)
x ** y x to the power y (the same as pow(x, y))
-Bit operators on integers and long integers
+Bit operators on integers
Bit operators
Operation >Result
@@ -948,9 +946,6 @@
eval(s[, globals[, Eval string s in (optional) globals, locals contexts.s must
locals]]) have no NUL's or newlines. s can also be acode object.
Example: x = 1; incr_x = eval('x + 1')
-execfile(file[, Executes a file without creating a new module, unlike
-globals[, locals]]) import.
-file() Synonym for open().
filter(function, Constructs a list from those elements of sequence for which
sequence) function returns true. function takes one parameter.
float(x) Converts a number or a string to floating point.
@@ -977,9 +972,6 @@
list(sequence) Converts sequence into a list. If already a list,returns a
copy of it.
locals() Returns a dictionary containing current local variables.
- Converts a number or a string to a long integer. Optional
-long(x[, base]) base paramenter specifies base from which to convert string
- values.
Applies function to every item of list and returns a listof
map(function, list, the results. If additional arguments are passed,function
...) must take that many arguments and it is givento function on
@@ -1167,7 +1159,7 @@
s^=o = __ixor__(s,o) s|=o = __ior__(s,o)
s<<=o = __ilshift__(s,o) s>>=o = __irshift__(s,o)
Conversions
- int(s) = __int__(s) long(s) = __long__(s)
+ int(s) = __int__(s)
float(s) = __float__(s) complex(s) = __complex__(s)
oct(s) = __oct__(s) hex(s) = __hex__(s)
Right-hand-side equivalents for all binary operators exist;
Modified: python/branches/py3k/Misc/python-mode.el
==============================================================================
--- python/branches/py3k/Misc/python-mode.el (original)
+++ python/branches/py3k/Misc/python-mode.el Sun Aug 12 02:43:29 2007
@@ -380,7 +380,7 @@
"bool" "buffer" "callable" "chr" "classmethod"
"cmp" "compile" "complex" "copyright"
"delattr" "dict" "dir" "divmod"
- "enumerate" "eval" "execfile" "exit" "file"
+ "enumerate" "eval" "exit" "file"
"filter" "float" "getattr" "globals" "hasattr"
"hash" "hex" "id" "int"
"isinstance" "issubclass" "iter" "len" "license"
@@ -1262,7 +1262,7 @@
;; Python subprocess utilities and filters
(defun py-execute-file (proc filename)
- "Send to Python interpreter process PROC \"execfile('FILENAME')\".
+ "Send to Python interpreter process PROC \"exec(open('FILENAME').read())\".
Make that process's buffer visible and force display. Also make
comint believe the user typed this string so that
`kill-output-from-shell' does The Right Thing."
@@ -1270,7 +1270,7 @@
(procbuf (process-buffer proc))
; (comint-scroll-to-bottom-on-output t)
(msg (format "## working on region in file %s...\n" filename))
- (cmd (format "execfile(r'%s')\n" filename)))
+ (cmd (format "exec(open(r'%s').read())\n" filename)))
(unwind-protect
(save-excursion
(set-buffer procbuf)
@@ -1606,7 +1606,7 @@
non-nil, specifies to run the command asynchronously in its own
buffer.
-If the Python interpreter shell is running, the region is execfile()'d
+If the Python interpreter shell is running, the region is exec()'d
in that shell. If you try to execute regions too quickly,
`python-mode' will queue them up and execute them one at a time when
it sees a `>>> ' prompt from Python. Each time this happens, the
@@ -1731,7 +1731,7 @@
If the file has already been imported, then do reload instead to get
the latest version.
-If the file's name does not end in \".py\", then do execfile instead.
+If the file's name does not end in \".py\", then do exec instead.
If the current buffer is not visiting a file, do `py-execute-buffer'
instead.
@@ -1768,7 +1768,7 @@
(file-name-nondirectory file))))
(format "if globals().has_key('%s'):\n reload(%s)\nelse:\n import %s\n"
f f f))
- (format "execfile(r'%s')\n" file))
+ (format "exec(open(r'%s'))\n" file))
async))
;; else
(py-execute-buffer async))))
Modified: python/branches/py3k/Objects/fileobject.c
==============================================================================
--- python/branches/py3k/Objects/fileobject.c (original)
+++ python/branches/py3k/Objects/fileobject.c Sun Aug 12 02:43:29 2007
@@ -317,7 +317,7 @@
** will cause a pause if we're reading from an
** interactive stream, but that is very unlikely
** unless we're doing something silly like
- ** execfile("/dev/tty").
+ ** exec(open("/dev/tty").read()).
*/
c = GETC(stream);
if ( c != '\n' )
Modified: python/branches/py3k/Python/bltinmodule.c
==============================================================================
--- python/branches/py3k/Python/bltinmodule.c (original)
+++ python/branches/py3k/Python/bltinmodule.c Sun Aug 12 02:43:29 2007
@@ -642,107 +642,6 @@
static PyObject *
-builtin_execfile(PyObject *self, PyObject *args)
-{
- char *filename;
- PyObject *globals = Py_None, *locals = Py_None;
- PyObject *res;
- FILE* fp = NULL;
- PyCompilerFlags cf;
- int exists;
-
- if (!PyArg_ParseTuple(args, "s|O!O:execfile",
- &filename,
- &PyDict_Type, &globals,
- &locals))
- return NULL;
- if (locals != Py_None && !PyMapping_Check(locals)) {
- PyErr_SetString(PyExc_TypeError, "locals must be a mapping");
- return NULL;
- }
- if (globals == Py_None) {
- globals = PyEval_GetGlobals();
- if (locals == Py_None)
- locals = PyEval_GetLocals();
- }
- else if (locals == Py_None)
- locals = globals;
- if (PyDict_GetItemString(globals, "__builtins__") == NULL) {
- if (PyDict_SetItemString(globals, "__builtins__",
- PyEval_GetBuiltins()) != 0)
- return NULL;
- }
-
- exists = 0;
- /* Test for existence or directory. */
-#if defined(PLAN9)
- {
- Dir *d;
-
- if ((d = dirstat(filename))!=nil) {
- if(d->mode & DMDIR)
- werrstr("is a directory");
- else
- exists = 1;
- free(d);
- }
- }
-#elif defined(RISCOS)
- if (object_exists(filename)) {
- if (isdir(filename))
- errno = EISDIR;
- else
- exists = 1;
- }
-#else /* standard Posix */
- {
- struct stat s;
- if (stat(filename, &s) == 0) {
- if (S_ISDIR(s.st_mode))
-# if defined(PYOS_OS2) && defined(PYCC_VACPP)
- errno = EOS2ERR;
-# else
- errno = EISDIR;
-# endif
- else
- exists = 1;
- }
- }
-#endif
-
- if (exists) {
- Py_BEGIN_ALLOW_THREADS
- fp = fopen(filename, "r" PY_STDIOTEXTMODE);
- Py_END_ALLOW_THREADS
-
- if (fp == NULL) {
- exists = 0;
- }
- }
-
- if (!exists) {
- PyErr_SetFromErrnoWithFilename(PyExc_IOError, filename);
- return NULL;
- }
- cf.cf_flags = 0;
- if (PyEval_MergeCompilerFlags(&cf))
- res = PyRun_FileExFlags(fp, filename, Py_file_input, globals,
- locals, 1, &cf);
- else
- res = PyRun_FileEx(fp, filename, Py_file_input, globals,
- locals, 1);
- return res;
-}
-
-PyDoc_STRVAR(execfile_doc,
-"execfile(filename[, globals[, locals]])\n\
-\n\
-Read and execute a Python script from a file.\n\
-The globals and locals are dictionaries, defaulting to the current\n\
-globals and locals. If only globals is given, locals defaults to it.");
-
-
-static PyObject *
builtin_getattr(PyObject *self, PyObject *args)
{
PyObject *v, *result, *dflt = NULL, *release = NULL;
@@ -1737,7 +1636,6 @@
{"divmod", builtin_divmod, METH_VARARGS, divmod_doc},
{"eval", builtin_eval, METH_VARARGS, eval_doc},
{"exec", builtin_exec, METH_VARARGS, exec_doc},
- {"execfile", builtin_execfile, METH_VARARGS, execfile_doc},
{"filter", builtin_filter, METH_VARARGS, filter_doc},
{"getattr", builtin_getattr, METH_VARARGS, getattr_doc},
{"globals", (PyCFunction)builtin_globals, METH_NOARGS, globals_doc},
Modified: python/branches/py3k/README
==============================================================================
--- python/branches/py3k/README (original)
+++ python/branches/py3k/README Sun Aug 12 02:43:29 2007
@@ -1101,7 +1101,7 @@
--with(out)-universal-newlines: enable reading of text files with
foreign newline convention (default: enabled). In other words,
any of \r, \n or \r\n is acceptable as end-of-line character.
- If enabled import and execfile will automatically accept any newline
+ If enabled import will automatically accept any newline
in files. Python code can open a file with open(file, 'U') to
read it in universal newline mode. THIS OPTION IS UNSUPPORTED.
Modified: python/branches/py3k/Tools/scripts/hotshotmain.py
==============================================================================
--- python/branches/py3k/Tools/scripts/hotshotmain.py (original)
+++ python/branches/py3k/Tools/scripts/hotshotmain.py Sun Aug 12 02:43:29 2007
@@ -23,7 +23,12 @@
prof = hotshot.Profile(profile)
sys.path.insert(0, os.path.dirname(filename))
sys.argv = [filename] + args
- prof.run("execfile(%r)" % filename)
+ fp = open(filename)
+ try:
+ script = fp.read()
+ finally:
+ fp.close()
+ prof.run("exec(%r)" % script)
prof.close()
stats = hotshot.stats.load(profile)
stats.sort_stats("time", "calls")
Modified: python/branches/py3k/Tools/versioncheck/README
==============================================================================
--- python/branches/py3k/Tools/versioncheck/README (original)
+++ python/branches/py3k/Tools/versioncheck/README Sun Aug 12 02:43:29 2007
@@ -19,7 +19,7 @@
of URLs. Each of these will be checked in order until one is available,
this is handy for distributions that live in multiple places. Put the
primary distribution site (the most up-to-date site) before others.
-The script is executed with execfile(), not imported, and the current
+The script is read and executed with exec(), not imported, and the current
directory is the checkversion directory, so be careful with globals,
importing, etc.
Modified: python/branches/py3k/Tools/versioncheck/checkversions.py
==============================================================================
--- python/branches/py3k/Tools/versioncheck/checkversions.py (original)
+++ python/branches/py3k/Tools/versioncheck/checkversions.py Sun Aug 12 02:43:29 2007
@@ -26,7 +26,7 @@
if CHECKNAME in files:
fullname = os.path.join(dir, CHECKNAME)
try:
- execfile(fullname)
+ exec(open(fullname).read())
except:
print('** Exception in', fullname)
Modified: python/branches/py3k/setup.py
==============================================================================
--- python/branches/py3k/setup.py (original)
+++ python/branches/py3k/setup.py Sun Aug 12 02:43:29 2007
@@ -1369,7 +1369,12 @@
return False
fficonfig = {}
- execfile(ffi_configfile, globals(), fficonfig)
+ fp = open(ffi_configfile)
+ try:
+ script = fp.read()
+ finally:
+ fp.close()
+ exec(script, globals(), fficonfig)
ffi_srcdir = os.path.join(fficonfig['ffi_srcdir'], 'src')
# Add .S (preprocessed assembly) to C compiler source extensions.
More information about the Python-3000-checkins
mailing list