summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-09-06 06:51:57 (GMT)
committerGeorg Brandl <georg@python.org>2006-09-06 06:51:57 (GMT)
commit7cae87ca7b0a3a7ce497cbd335c8ec82fe680476 (patch)
tree612cc46e728bef49b19f3d4bc26fa4951b2c1c83
parent4e472e05bdddde72d91d6f25d6e048371cf3c9be (diff)
downloadcpython-7cae87ca7b0a3a7ce497cbd335c8ec82fe680476.zip
cpython-7cae87ca7b0a3a7ce497cbd335c8ec82fe680476.tar.gz
cpython-7cae87ca7b0a3a7ce497cbd335c8ec82fe680476.tar.bz2
Patch #1550800: make exec a function.
-rw-r--r--Demo/parser/unparse.py10
-rwxr-xr-xDemo/pysvr/pysvr.py2
-rwxr-xr-xDemo/sockets/rpythond.py2
-rw-r--r--Doc/howto/doanddont.tex6
-rw-r--r--Doc/lib/libdis.tex5
-rw-r--r--Doc/lib/libexcs.tex8
-rw-r--r--Doc/lib/libfuncs.tex46
-rw-r--r--Doc/lib/libhotshot.tex4
-rw-r--r--Doc/lib/libparser.tex5
-rw-r--r--Doc/lib/libpdb.tex4
-rw-r--r--Doc/lib/libprofile.tex6
-rw-r--r--Doc/lib/librexec.tex6
-rw-r--r--Doc/lib/libstdtypes.tex6
-rw-r--r--Doc/lib/libtraceback.tex2
-rw-r--r--Doc/ref/ref2.tex13
-rw-r--r--Doc/ref/ref4.tex18
-rw-r--r--Doc/ref/ref6.tex65
-rw-r--r--Doc/ref/ref8.tex2
-rw-r--r--Doc/ref/reswords.py2
-rw-r--r--Doc/tut/tut.tex6
-rw-r--r--Grammar/Grammar3
-rw-r--r--Include/Python-ast.h12
-rw-r--r--Include/graminit.h101
-rw-r--r--Include/opcode.h2
-rw-r--r--Include/symtable.h6
-rw-r--r--Lib/Bastion.py2
-rw-r--r--Lib/bdb.py2
-rw-r--r--Lib/bsddb/__init__.py4
-rwxr-xr-xLib/cProfile.py2
-rwxr-xr-xLib/cgi.py2
-rw-r--r--Lib/code.py2
-rw-r--r--Lib/compiler/ast.py26
-rw-r--r--Lib/compiler/pyassem.py1
-rw-r--r--Lib/compiler/pycodegen.py12
-rw-r--r--Lib/compiler/transformer.py15
-rw-r--r--Lib/doctest.py4
-rw-r--r--Lib/hashlib.py4
-rw-r--r--Lib/idlelib/PyShell.py4
-rw-r--r--Lib/idlelib/run.py2
-rw-r--r--Lib/ihooks.py2
-rw-r--r--Lib/imputil.py2
-rwxr-xr-xLib/keyword.py1
-rw-r--r--Lib/lib-tk/Tkinter.py2
-rw-r--r--Lib/opcode.py1
-rwxr-xr-xLib/pdb.py2
-rwxr-xr-xLib/plat-irix5/flp.py6
-rwxr-xr-xLib/plat-irix5/panel.py6
-rw-r--r--Lib/plat-irix6/flp.py6
-rw-r--r--Lib/plat-irix6/panel.py6
-rw-r--r--Lib/plat-mac/aetypes.py18
-rw-r--r--Lib/plat-mac/appletrawmain.py2
-rw-r--r--Lib/plat-mac/pimp.py4
-rwxr-xr-xLib/profile.py2
-rw-r--r--Lib/rexec.py4
-rwxr-xr-xLib/runpy.py2
-rw-r--r--Lib/site.py2
-rw-r--r--Lib/socket.py2
-rwxr-xr-xLib/symbol.py101
-rw-r--r--Lib/test/crashers/bogus_code_obj.py2
-rw-r--r--Lib/test/output/test_cProfile7
-rw-r--r--Lib/test/output/test_grammar1
-rw-r--r--Lib/test/output/test_profile11
-rw-r--r--Lib/test/test___all__.py4
-rw-r--r--Lib/test/test_ast.py3
-rw-r--r--Lib/test/test_binop.py2
-rw-r--r--Lib/test/test_builtin.py27
-rw-r--r--Lib/test/test_class.py4
-rw-r--r--Lib/test/test_codeop.py4
-rw-r--r--Lib/test/test_compile.py31
-rw-r--r--Lib/test/test_compiler.py6
-rw-r--r--Lib/test/test_descr.py8
-rw-r--r--Lib/test/test_descrtut.py2
-rw-r--r--Lib/test/test_dis.py2
-rw-r--r--Lib/test/test_doctest.py4
-rw-r--r--Lib/test/test_exceptions.py2
-rw-r--r--Lib/test/test_funcattrs.py2
-rw-r--r--Lib/test/test_gc.py2
-rw-r--r--Lib/test/test_getopt.py2
-rw-r--r--Lib/test/test_grammar.py36
-rw-r--r--Lib/test/test_import.py2
-rw-r--r--Lib/test/test_importhooks.py2
-rw-r--r--Lib/test/test_inspect.py2
-rw-r--r--Lib/test/test_multibytecodec.py2
-rw-r--r--Lib/test/test_operations.py2
-rw-r--r--Lib/test/test_parser.py2
-rw-r--r--Lib/test/test_scope.py15
-rw-r--r--Lib/test/test_transformer.py2
-rw-r--r--Lib/test/time_hashlib.py10
-rw-r--r--Lib/timeit.py2
-rw-r--r--Lib/trace.py4
-rw-r--r--Misc/vgrindefs2
-rw-r--r--Modules/parsermodule.c36
-rw-r--r--Modules/symtablemodule.c3
-rw-r--r--Parser/Python.asdl5
-rw-r--r--Python/Python-ast.c52
-rw-r--r--Python/ast.c36
-rw-r--r--Python/bltinmodule.c111
-rw-r--r--Python/ceval.c117
-rw-r--r--Python/compile.c17
-rw-r--r--Python/graminit.c1559
-rw-r--r--Python/symtable.c28
-rw-r--r--Tools/compiler/ast.txt1
-rwxr-xr-xTools/modulator/modulator.py4
-rwxr-xr-xTools/scripts/fixdiv.py2
-rwxr-xr-xTools/scripts/h2py.py4
105 files changed, 1221 insertions, 1558 deletions
diff --git a/Demo/parser/unparse.py b/Demo/parser/unparse.py
index 510cdb0..f3a5ffe 100644
--- a/Demo/parser/unparse.py
+++ b/Demo/parser/unparse.py
@@ -123,16 +123,6 @@ class Unparser:
self.write(", ")
self.dispatch(t.msg)
- def _Exec(self, t):
- self.fill("exec ")
- self.dispatch(t.body)
- if t.globals:
- self.write(" in ")
- self.dispatch(t.globals)
- if t.locals:
- self.write(", ")
- self.dispatch(t.locals)
-
def _Print(self, t):
self.fill("print ")
do_comma = False
diff --git a/Demo/pysvr/pysvr.py b/Demo/pysvr/pysvr.py
index dd0abdc..3b692b3 100755
--- a/Demo/pysvr/pysvr.py
+++ b/Demo/pysvr/pysvr.py
@@ -108,7 +108,7 @@ def run_command(code, stdin, stdout, globals):
sys.stdout = sys.stderr = stdout
sys.stdin = stdin
try:
- exec code in globals
+ exec(code, globals)
except SystemExit, how:
raise SystemExit, how, sys.exc_info()[2]
except:
diff --git a/Demo/sockets/rpythond.py b/Demo/sockets/rpythond.py
index 81397d6..34de982 100755
--- a/Demo/sockets/rpythond.py
+++ b/Demo/sockets/rpythond.py
@@ -40,7 +40,7 @@ def execute(request):
sys.stdout = sys.stderr = fakefile = StringIO.StringIO()
try:
try:
- exec request in {}, {}
+ exec(request, {}, {})
except:
print
traceback.print_exc(100)
diff --git a/Doc/howto/doanddont.tex b/Doc/howto/doanddont.tex
index df3ca34..d81c374 100644
--- a/Doc/howto/doanddont.tex
+++ b/Doc/howto/doanddont.tex
@@ -81,7 +81,7 @@ There are situations in which \code{from module import *} is just fine:
\end{itemize}
-\subsection{Unadorned \keyword{exec}, \function{execfile} and friends}
+\subsection{Unadorned \function{exec}, \function{execfile} 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.
@@ -93,10 +93,10 @@ Bad examples:
\begin{verbatim}
>>> for name in sys.argv[1:]:
->>> exec "%s=1" % name
+>>> exec("%s=1" % name)
>>> def func(s, **kw):
>>> for var, val in kw.items():
->>> exec "s.%s=val" % var # invalid!
+>>> exec("s.%s=val" % var) # invalid!
>>> execfile("handler.py")
>>> handle()
\end{verbatim}
diff --git a/Doc/lib/libdis.tex b/Doc/lib/libdis.tex
index 5c53490..e61ca36 100644
--- a/Doc/lib/libdis.tex
+++ b/Doc/lib/libdis.tex
@@ -408,11 +408,6 @@ to the local namespace. The module is popped after loading all names.
This opcode implements \code{from module import *}.
\end{opcodedesc}
-\begin{opcodedesc}{EXEC_STMT}{}
-Implements \code{exec TOS2,TOS1,TOS}. The compiler fills
-missing optional parameters with \code{None}.
-\end{opcodedesc}
-
\begin{opcodedesc}{POP_BLOCK}{}
Removes one block from the block stack. Per frame, there is a
stack of blocks, denoting nested loops, try statements, and such.
diff --git a/Doc/lib/libexcs.tex b/Doc/lib/libexcs.tex
index b64d57d..b6147bf 100644
--- a/Doc/lib/libexcs.tex
+++ b/Doc/lib/libexcs.tex
@@ -293,10 +293,10 @@ Raised when an \keyword{assert} statement fails.
\begin{excdesc}{SyntaxError}
% XXXJH xref to these functions?
Raised when the parser encounters a syntax error. This may occur in
- an \keyword{import} statement, in an \keyword{exec} statement, in a call
- to the built-in function \function{eval()} or \function{input()}, or
- when reading the initial script or standard input (also
- interactively).
+ an \keyword{import} statement, in a call to the built-in functions
+ \function{exec()}, \function{execfile()}, \function{eval()} or
+ \function{input()}, or when reading the initial script or standard
+ input (also interactively).
Instances of this class have attributes \member{filename},
\member{lineno}, \member{offset} and \member{text} for easier access
diff --git a/Doc/lib/libfuncs.tex b/Doc/lib/libfuncs.tex
index f51f0d5..4dde065 100644
--- a/Doc/lib/libfuncs.tex
+++ b/Doc/lib/libfuncs.tex
@@ -178,7 +178,7 @@ class C:
\begin{funcdesc}{compile}{string, filename, kind\optional{,
flags\optional{, dont_inherit}}}
Compile the \var{string} into a code object. Code objects can be
- executed by an \keyword{exec} statement or evaluated by a call to
+ executed by a call to \function{exec()} or evaluated by a call to
\function{eval()}. The \var{filename} argument should
give the file from which the code was read; pass some recognizable value
if it wasn't read from a file (\code{'<string>'} is commonly used).
@@ -366,7 +366,7 @@ class C:
compiled passing \code{'eval'} as the \var{kind} argument.
Hints: dynamic execution of statements is supported by the
- \keyword{exec} statement. Execution of statements from a file is
+ \function{exec()} function. Execution of statements from a file is
supported by the \function{execfile()} function. The
\function{globals()} and \function{locals()} functions returns the
current global and local dictionary, respectively, which may be
@@ -374,13 +374,47 @@ class C:
\function{execfile()}.
\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
+ a code object. If it is a string, the string is parsed as a suite of
+ Python statements which is then executed (unless a syntax error
+ occurs). If it is an open file, the file is parsed until \EOF{} and
+ executed. If it is a code object, it is simply executed. In all
+ cases, the code that's executed is expected to be valid as file
+ input (see the section ``File input'' in the Reference Manual).
+ Be aware that the \keyword{return} and \keyword{yield} statements may
+ not be used outside of function definitions even within the context of
+ code passed to the \function{exec()} function.
+ The return value is \code{None}.
+
+ In all cases, if the optional parts are omitted, the code is executed
+ in the current scope. If only \var{globals} is provided, it must be
+ a dictionary, which will be used for both the global and the local
+ variables. If \var{globals} and \var{locals} are given, they are used
+ for the global and local variables, respectively. If provided,
+ \var{locals} can be any mapping object.
+
+ If the \var{globals} dictionary does not contain a value for the
+ key \code{__builtins__}, a reference to the dictionary of the built-in
+ module \module{__builtin__} is inserted under that key. That way you
+ can control what builtins are available to the executed code by
+ inserting your own \code{__builtins__} dictionary into \var{globals}
+ before passing it to \function{exec()}.
+
+ \note{The built-in functions \function{globals()} and \function{locals()}
+ return the current global and local dictionary, respectively, which
+ may be useful to pass around for use as the second and third
+ argument to \function{exec()}.}
+\end{funcdesc}
+
\begin{funcdesc}{execfile}{filename\optional{, globals\optional{, locals}}}
- This function is similar to the
- \keyword{exec} statement, but parses a file instead of a string. It
+ 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.\footnote{It is used relatively
- rarely so does not warrant being made into a statement.}
+ 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
diff --git a/Doc/lib/libhotshot.tex b/Doc/lib/libhotshot.tex
index 98e0b6d..ae089c2 100644
--- a/Doc/lib/libhotshot.tex
+++ b/Doc/lib/libhotshot.tex
@@ -61,7 +61,7 @@ Return the file descriptor of the profiler's log file.
\end{methoddesc}
\begin{methoddesc}{run}{cmd}
-Profile an \keyword{exec}-compatible string in the script environment.
+Profile an \function{exec()}-compatible string in the script environment.
The globals from the \refmodule[main]{__main__} module are used as
both the globals and locals for the script.
\end{methoddesc}
@@ -76,7 +76,7 @@ disabled on the way out.
\begin{methoddesc}{runctx}{cmd, globals, locals}
-Evaluate an \keyword{exec}-compatible string in a specific environment.
+Profile an \function{exec()}-compatible string in a specific environment.
The string is compiled before profiling begins.
\end{methoddesc}
diff --git a/Doc/lib/libparser.tex b/Doc/lib/libparser.tex
index 15b46ae..a993624 100644
--- a/Doc/lib/libparser.tex
+++ b/Doc/lib/libparser.tex
@@ -193,8 +193,9 @@ false or omitted.
\begin{funcdesc}{compileast}{ast\optional{, filename\code{ = '<ast>'}}}
The Python byte compiler can be invoked on an AST object to produce
-code objects which can be used as part of an \keyword{exec} statement or
-a call to the built-in \function{eval()}\bifuncindex{eval} function.
+code objects which can be used as part of a call to the built-in
+\function{exec()}\bifuncindex{exec} or \function{eval()}
+\bifuncindex{eval} functions.
This function provides the interface to the compiler, passing the
internal parse tree from \var{ast} to the parser, using the
source file name specified by the \var{filename} parameter.
diff --git a/Doc/lib/libpdb.tex b/Doc/lib/libpdb.tex
index b252aeb..778a137 100644
--- a/Doc/lib/libpdb.tex
+++ b/Doc/lib/libpdb.tex
@@ -79,8 +79,8 @@ the statement using \samp{step} or \samp{next} (all these commands are
explained below). The optional \var{globals} and \var{locals}
arguments specify the environment in which the code is executed; by
default the dictionary of the module \refmodule[main]{__main__} is
-used. (See the explanation of the \keyword{exec} statement or the
-\function{eval()} built-in function.)
+used. (See the explanation of the built-in \function{exec()} or
+\function{eval()} functions.)
\end{funcdesc}
\begin{funcdesc}{runeval}{expression\optional{, globals\optional{, locals}}}
diff --git a/Doc/lib/libprofile.tex b/Doc/lib/libprofile.tex
index 0108b21..79a168c 100644
--- a/Doc/lib/libprofile.tex
+++ b/Doc/lib/libprofile.tex
@@ -319,9 +319,9 @@ code for these modules.
\begin{funcdesc}{run}{command\optional{, filename}}
-This function takes a single argument that has can be passed to the
-\keyword{exec} statement, and an optional file name. In all cases this
-routine attempts to \keyword{exec} its first argument, and gather profiling
+This function takes a single argument that can be passed to the
+\function{exec()} function, and an optional file name. In all cases this
+routine attempts to \function{exec()} its first argument, and gather profiling
statistics from the execution. If no file name is present, then this
function automatically prints a simple profiling report, sorted by the
standard name string (file/line/function-name) that is presented in
diff --git a/Doc/lib/librexec.tex b/Doc/lib/librexec.tex
index 35619e6..3e54102 100644
--- a/Doc/lib/librexec.tex
+++ b/Doc/lib/librexec.tex
@@ -11,10 +11,10 @@
\end{notice}
This module contains the \class{RExec} class, which supports
-\method{r_eval()}, \method{r_execfile()}, \method{r_exec()}, and
+\method{r_exec()}, \method{r_eval()}, \method{r_execfile()}, and
\method{r_import()} methods, which are restricted versions of the standard
-Python functions \method{eval()}, \method{execfile()} and
-the \keyword{exec} and \keyword{import} statements.
+Python functions \method{exec()}, \method{eval()}, \method{execfile()} and
+the \keyword{import} statement.
Code executed in this restricted environment will
only have access to modules and functions that are deemed safe; you
can subclass \class{RExec} to add or remove capabilities as desired.
diff --git a/Doc/lib/libstdtypes.tex b/Doc/lib/libstdtypes.tex
index b84daf4..ef1b802 100644
--- a/Doc/lib/libstdtypes.tex
+++ b/Doc/lib/libstdtypes.tex
@@ -1972,9 +1972,9 @@ attribute.
\withsubitem{(function object attribute)}{\ttindex{func_code}}
A code object can be executed or evaluated by passing it (instead of a
-source string) to the \keyword{exec} statement or the built-in
-\function{eval()} function.
-\stindex{exec}
+source string) to the \function{exec()} or \function{eval()}
+built-in functions.
+\bifuncindex{exec}
\bifuncindex{eval}
See the \citetitle[../ref/ref.html]{Python Reference Manual} for more
diff --git a/Doc/lib/libtraceback.tex b/Doc/lib/libtraceback.tex
index 80dc423..a87b1ef 100644
--- a/Doc/lib/libtraceback.tex
+++ b/Doc/lib/libtraceback.tex
@@ -139,7 +139,7 @@ import sys, traceback
def run_user_code(envdir):
source = raw_input(">>> ")
try:
- exec source in envdir
+ exec(source, envdir)
except:
print "Exception in user code:"
print '-'*60
diff --git a/Doc/ref/ref2.tex b/Doc/ref/ref2.tex
index f82d9ce..39b75a9 100644
--- a/Doc/ref/ref2.tex
+++ b/Doc/ref/ref2.tex
@@ -308,13 +308,12 @@ identifiers. They must be spelled exactly as written here:%
\index{reserved word}
\begin{verbatim}
-and del from not while
-as elif global or with
-assert else if pass yield
-break except import print
-class exec in raise
-continue finally is return
-def for lambda try
+and def for is raise
+as del from lambda return
+assert elif global not try
+break else if or while
+class except import pass with
+continue finally in print yield
\end{verbatim}
% When adding keywords, use reswords.py for reformatting
diff --git a/Doc/ref/ref4.tex b/Doc/ref/ref4.tex
index 12a2b92..c8b536e 100644
--- a/Doc/ref/ref4.tex
+++ b/Doc/ref/ref4.tex
@@ -20,8 +20,8 @@ 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 function
-\function{eval()} and to the \keyword{exec} statement is a code block.
+is a code 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,22 +139,16 @@ If the wild card form of import --- \samp{import *} --- is used in a
function and the function contains or is a nested block with free
variables, the compiler will raise a \exception{SyntaxError}.
-If \keyword{exec} is used in a function and the function contains or
-is a nested block with free variables, the compiler will raise a
-\exception{SyntaxError} unless the exec explicitly specifies the local
-namespace for the \keyword{exec}. (In other words, \samp{exec obj}
-would be illegal, but \samp{exec obj in ns} would be legal.)
-
-The \function{eval()}, \function{execfile()}, and \function{input()}
-functions and the \keyword{exec} statement do not have access to the
+The \function{eval()}, \function{exec()}, \function{execfile()},
+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
resolved in the nearest enclosing namespace, but in the global
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 \keyword{exec} statement and the \function{eval()} and
-\function{execfile()} functions have optional arguments to override
+The \function{exec()}, \function{eval()} and \function{execfile()}
+functions have optional arguments to override
the global and local namespace. If only one namespace is specified,
it is used for both.
diff --git a/Doc/ref/ref6.tex b/Doc/ref/ref6.tex
index 04db013..c1bbd9b 100644
--- a/Doc/ref/ref6.tex
+++ b/Doc/ref/ref6.tex
@@ -20,7 +20,6 @@ by semicolons. The syntax for simple statements is:
\productioncont{| \token{continue_stmt}}
\productioncont{| \token{import_stmt}}
\productioncont{| \token{global_stmt}}
- \productioncont{| \token{exec_stmt}}
\end{productionlist}
@@ -809,7 +808,7 @@ import __future__ [as name]
That is not a future statement; it's an ordinary import statement with
no special semantics or syntax restrictions.
-Code compiled by an \keyword{exec} statement or calls to the builtin functions
+Code compiled by calls to the builtin functions \function{exec()},
\function{compile()} and \function{execfile()} 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,
@@ -855,64 +854,14 @@ program.)
\strong{Programmer's note:}
the \keyword{global} is a directive to the parser. It
applies only to code parsed at the same time as the \keyword{global}
-statement. In particular, a \keyword{global} statement contained in an
-\keyword{exec} statement does not affect the code block \emph{containing}
-the \keyword{exec} statement, and code contained in an \keyword{exec}
-statement is unaffected by \keyword{global} statements in the code
-containing the \keyword{exec} statement. The same applies to the
+statement. In particular, a \keyword{global} statement contained in a
+string or code object supplied to the builtin \function{exec()} function
+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.
-\stindex{exec}
+\bifuncindex{exec}
\bifuncindex{eval}
\bifuncindex{execfile}
\bifuncindex{compile}
-
-\section{The \keyword{exec} statement \label{exec}}
-\stindex{exec}
-
-\begin{productionlist}
- \production{exec_stmt}
- {"exec" \token{expression}
- ["in" \token{expression} ["," \token{expression}]]}
-\end{productionlist}
-
-This statement supports dynamic execution of Python code. The first
-expression should evaluate to either a string, an open file object, or
-a code object. If it is a string, the string is parsed as a suite of
-Python statements which is then executed (unless a syntax error
-occurs). If it is an open file, the file is parsed until \EOF{} and
-executed. If it is a code object, it is simply executed. In all
-cases, the code that's executed is expected to be valid as file
-input (see section~\ref{file-input}, ``File input''). Be aware that
-the \keyword{return} and \keyword{yield} statements may not be used
-outside of function definitions even within the context of code passed
-to the \keyword{exec} statement.
-
-In all cases, if the optional parts are omitted, the code is executed
-in the current scope. If only the first expression after \keyword{in}
-is specified, it should be a dictionary, which will be used for both
-the global and the local variables. If two expressions are given,
-they are used for the global and local variables, respectively.
-If provided, \var{locals} can be any mapping object.
-\versionchanged[formerly \var{locals} was required to be a dictionary]{2.4}
-
-As a side effect, an implementation may insert additional keys into
-the dictionaries given besides those corresponding to variable names
-set by the executed code. For example, the current implementation
-may add a reference to the dictionary of the built-in module
-\module{__builtin__} under the key \code{__builtins__} (!).
-\ttindex{__builtins__}
-\refbimodindex{__builtin__}
-
-\strong{Programmer's hints:}
-dynamic evaluation of expressions is supported by the built-in
-function \function{eval()}. The built-in functions
-\function{globals()} and \function{locals()} return the current global
-and local dictionary, respectively, which may be useful to pass around
-for use by \keyword{exec}.
-\bifuncindex{eval}
-\bifuncindex{globals}
-\bifuncindex{locals}
-
-
-
diff --git a/Doc/ref/ref8.tex b/Doc/ref/ref8.tex
index 45be71d..3fe4cc5 100644
--- a/Doc/ref/ref8.tex
+++ b/Doc/ref/ref8.tex
@@ -62,7 +62,7 @@ This syntax is used in the following situations:
\item when parsing a module;
-\item when parsing a string passed to the \keyword{exec} statement;
+\item when parsing a string passed to the \function{exec()} function;
\end{itemize}
diff --git a/Doc/ref/reswords.py b/Doc/ref/reswords.py
index 68862bb..53b8dc8 100644
--- a/Doc/ref/reswords.py
+++ b/Doc/ref/reswords.py
@@ -9,7 +9,7 @@ def main():
words.sort()
colwidth = 1 + max(map(len, words))
nwords = len(words)
- nrows = (nwords + ncols - 1) / ncols
+ nrows = (nwords + ncols - 1) // ncols
for irow in range(nrows):
for icol in range(ncols):
i = irow + icol * nrows
diff --git a/Doc/tut/tut.tex b/Doc/tut/tut.tex
index 702d759..2daf812 100644
--- a/Doc/tut/tut.tex
+++ b/Doc/tut/tut.tex
@@ -2698,7 +2698,7 @@ standard module \module{__builtin__}\refbimodindex{__builtin__}:
'__name__', 'abs', 'basestring', 'bool', 'buffer',
'callable', 'chr', 'classmethod', 'cmp', 'compile',
'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod',
- 'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', 'float',
+ 'enumerate', 'eval', 'exec', 'execfile', 'exit', 'file', 'filter', 'float',
'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex',
'id', 'int', 'intern', 'isinstance', 'issubclass', 'iter',
'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'min',
@@ -4362,8 +4362,8 @@ the debugger, and that's one reason why this loophole is not closed.
(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{evalfile()} does not consider the classname of the invoking
+Notice that code passed to \code{exec()}, \code{eval()} or
+\code{execfile()} 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
diff --git a/Grammar/Grammar b/Grammar/Grammar
index 2e964f2..281ae6b 100644
--- a/Grammar/Grammar
+++ b/Grammar/Grammar
@@ -32,7 +32,7 @@ fplist: fpdef (',' fpdef)* [',']
stmt: simple_stmt | compound_stmt
simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE
small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt |
- import_stmt | global_stmt | exec_stmt | assert_stmt)
+ import_stmt | global_stmt | assert_stmt)
expr_stmt: testlist (augassign (yield_expr|testlist) |
('=' (yield_expr|testlist))*)
augassign: ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' |
@@ -58,7 +58,6 @@ import_as_names: import_as_name (',' import_as_name)* [',']
dotted_as_names: dotted_as_name (',' dotted_as_name)*
dotted_name: NAME ('.' NAME)*
global_stmt: 'global' NAME (',' NAME)*
-exec_stmt: 'exec' expr ['in' test [',' test]]
assert_stmt: 'assert' test [',' test]
compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef
diff --git a/Include/Python-ast.h b/Include/Python-ast.h
index 390b8ea..2b817c6 100644
--- a/Include/Python-ast.h
+++ b/Include/Python-ast.h
@@ -64,8 +64,8 @@ enum _stmt_kind {FunctionDef_kind=1, ClassDef_kind=2, Return_kind=3,
For_kind=8, While_kind=9, If_kind=10, With_kind=11,
Raise_kind=12, TryExcept_kind=13, TryFinally_kind=14,
Assert_kind=15, Import_kind=16, ImportFrom_kind=17,
- Exec_kind=18, Global_kind=19, Expr_kind=20, Pass_kind=21,
- Break_kind=22, Continue_kind=23};
+ Global_kind=18, Expr_kind=19, Pass_kind=20, Break_kind=21,
+ Continue_kind=22};
struct _stmt {
enum _stmt_kind kind;
union {
@@ -165,12 +165,6 @@ struct _stmt {
} ImportFrom;
struct {
- expr_ty body;
- expr_ty globals;
- expr_ty locals;
- } Exec;
-
- struct {
asdl_seq *names;
} Global;
@@ -384,8 +378,6 @@ stmt_ty Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, PyArena
stmt_ty Import(asdl_seq * names, int lineno, int col_offset, PyArena *arena);
stmt_ty ImportFrom(identifier module, asdl_seq * names, int level, int lineno,
int col_offset, PyArena *arena);
-stmt_ty Exec(expr_ty body, expr_ty globals, expr_ty locals, int lineno, int
- col_offset, PyArena *arena);
stmt_ty Global(asdl_seq * names, int lineno, int col_offset, PyArena *arena);
stmt_ty Expr(expr_ty value, int lineno, int col_offset, PyArena *arena);
stmt_ty Pass(int lineno, int col_offset, PyArena *arena);
diff --git a/Include/graminit.h b/Include/graminit.h
index f4701a6..61c0814 100644
--- a/Include/graminit.h
+++ b/Include/graminit.h
@@ -31,54 +31,53 @@
#define dotted_as_names 286
#define dotted_name 287
#define global_stmt 288
-#define exec_stmt 289
-#define assert_stmt 290
-#define compound_stmt 291
-#define if_stmt 292
-#define while_stmt 293
-#define for_stmt 294
-#define try_stmt 295
-#define with_stmt 296
-#define with_var 297
-#define except_clause 298
-#define suite 299
-#define testlist_safe 300
-#define old_test 301
-#define old_lambdef 302
-#define test 303
-#define or_test 304
-#define and_test 305
-#define not_test 306
-#define comparison 307
-#define comp_op 308
-#define expr 309
-#define xor_expr 310
-#define and_expr 311
-#define shift_expr 312
-#define arith_expr 313
-#define term 314
-#define factor 315
-#define power 316
-#define atom 317
-#define listmaker 318
-#define testlist_gexp 319
-#define lambdef 320
-#define trailer 321
-#define subscriptlist 322
-#define subscript 323
-#define sliceop 324
-#define exprlist 325
-#define testlist 326
-#define dictsetmaker 327
-#define classdef 328
-#define arglist 329
-#define argument 330
-#define list_iter 331
-#define list_for 332
-#define list_if 333
-#define gen_iter 334
-#define gen_for 335
-#define gen_if 336
-#define testlist1 337
-#define encoding_decl 338
-#define yield_expr 339
+#define assert_stmt 289
+#define compound_stmt 290
+#define if_stmt 291
+#define while_stmt 292
+#define for_stmt 293
+#define try_stmt 294
+#define with_stmt 295
+#define with_var 296
+#define except_clause 297
+#define suite 298
+#define testlist_safe 299
+#define old_test 300
+#define old_lambdef 301
+#define test 302
+#define or_test 303
+#define and_test 304
+#define not_test 305
+#define comparison 306
+#define comp_op 307
+#define expr 308
+#define xor_expr 309
+#define and_expr 310
+#define shift_expr 311
+#define arith_expr 312
+#define term 313
+#define factor 314
+#define power 315
+#define atom 316
+#define listmaker 317
+#define testlist_gexp 318
+#define lambdef 319
+#define trailer 320
+#define subscriptlist 321
+#define subscript 322
+#define sliceop 323
+#define exprlist 324
+#define testlist 325
+#define dictsetmaker 326
+#define classdef 327
+#define arglist 328
+#define argument 329
+#define list_iter 330
+#define list_for 331
+#define list_if 332
+#define gen_iter 333
+#define gen_for 334
+#define gen_if 335
+#define testlist1 336
+#define encoding_decl 337
+#define yield_expr 338
diff --git a/Include/opcode.h b/Include/opcode.h
index 4c823d9..04675dd 100644
--- a/Include/opcode.h
+++ b/Include/opcode.h
@@ -75,7 +75,7 @@ extern "C" {
#define LOAD_LOCALS 82
#define RETURN_VALUE 83
#define IMPORT_STAR 84
-#define EXEC_STMT 85
+
#define YIELD_VALUE 86
#define POP_BLOCK 87
#define END_FINALLY 88
diff --git a/Include/symtable.h b/Include/symtable.h
index 1e5996d..f40bfa4 100644
--- a/Include/symtable.h
+++ b/Include/symtable.h
@@ -88,11 +88,9 @@ PyAPI_FUNC(void) PySymtable_Free(struct symtable *);
#define FREE 4
#define CELL 5
-/* The following three names are used for the ste_unoptimized bit field */
+/* The following two names are used for the ste_unoptimized bit field */
#define OPT_IMPORT_STAR 1
-#define OPT_EXEC 2
-#define OPT_BARE_EXEC 4
-#define OPT_TOPLEVEL 8 /* top-level names, including eval and exec */
+#define OPT_TOPLEVEL 2 /* top-level names, including eval and exec */
#define GENERATOR 1
#define GENERATOR_EXPRESSION 2
diff --git a/Lib/Bastion.py b/Lib/Bastion.py
index 58cce97..2127f46 100644
--- a/Lib/Bastion.py
+++ b/Lib/Bastion.py
@@ -164,7 +164,7 @@ def _test():
else:
print "accessible"
\n"""
- exec testcode
+ exec(testcode)
print '='*20, "Using rexec:", '='*20
import rexec
r = rexec.RExec()
diff --git a/Lib/bdb.py b/Lib/bdb.py
index 1e81c44..11cce42 100644
--- a/Lib/bdb.py
+++ b/Lib/bdb.py
@@ -362,7 +362,7 @@ class Bdb:
cmd = cmd+'\n'
try:
try:
- exec cmd in globals, locals
+ exec(cmd, globals, locals)
except BdbQuit:
pass
finally:
diff --git a/Lib/bsddb/__init__.py b/Lib/bsddb/__init__.py
index 0eeefd1..3099bb3 100644
--- a/Lib/bsddb/__init__.py
+++ b/Lib/bsddb/__init__.py
@@ -72,7 +72,7 @@ import sys, os
if sys.version >= '2.3':
import UserDict
from weakref import ref
- exec """
+ exec("""
class _iter_mixin(UserDict.DictMixin):
def _make_iter_cursor(self):
cur = _DeadlockWrap(self.db.cursor)
@@ -145,7 +145,7 @@ class _iter_mixin(UserDict.DictMixin):
except _bsddb.DBCursorClosedError:
# the database was modified during iteration. abort.
return
-"""
+""")
else:
class _iter_mixin: pass
diff --git a/Lib/cProfile.py b/Lib/cProfile.py
index 19d5804..cb26fe1 100755
--- a/Lib/cProfile.py
+++ b/Lib/cProfile.py
@@ -137,7 +137,7 @@ class Profile(_lsprof.Profiler):
def runctx(self, cmd, globals, locals):
self.enable()
try:
- exec cmd in globals, locals
+ exec(cmd, globals, locals)
finally:
self.disable()
return self
diff --git a/Lib/cgi.py b/Lib/cgi.py
index 47c0279..fa8fd13 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -910,7 +910,7 @@ def test(environ=os.environ):
print_environ(environ)
print_environ_usage()
def f():
- exec "testing print_exception() -- <I>italics?</I>"
+ exec("testing print_exception() -- <I>italics?</I>")
def g(f=f):
f()
print "<H3>What follows is a test, not an actual exception:</H3>"
diff --git a/Lib/code.py b/Lib/code.py
index b67009b..8d3a884 100644
--- a/Lib/code.py
+++ b/Lib/code.py
@@ -100,7 +100,7 @@ class InteractiveInterpreter:
"""
try:
- exec code in self.locals
+ exec(code, self.locals)
except SystemExit:
raise
except:
diff --git a/Lib/compiler/ast.py b/Lib/compiler/ast.py
index 6953325..b06531f 100644
--- a/Lib/compiler/ast.py
+++ b/Lib/compiler/ast.py
@@ -440,32 +440,6 @@ class Ellipsis(Node):
def __repr__(self):
return "Ellipsis()"
-class Exec(Node):
- def __init__(self, expr, locals, globals, lineno=None):
- self.expr = expr
- self.locals = locals
- self.globals = globals
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.append(self.expr)
- children.append(self.locals)
- children.append(self.globals)
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.append(self.expr)
- if self.locals is not None:
- nodelist.append(self.locals)
- if self.globals is not None:
- nodelist.append(self.globals)
- return tuple(nodelist)
-
- def __repr__(self):
- return "Exec(%s, %s, %s)" % (repr(self.expr), repr(self.locals), repr(self.globals))
-
class FloorDiv(Node):
def __init__(self, (left, right), lineno=None):
self.left = left
diff --git a/Lib/compiler/pyassem.py b/Lib/compiler/pyassem.py
index 542d704..5e3eb30 100644
--- a/Lib/compiler/pyassem.py
+++ b/Lib/compiler/pyassem.py
@@ -762,7 +762,6 @@ class StackDepthTracker:
'PRINT_ITEM': -1,
'RETURN_VALUE': -1,
'YIELD_VALUE': -1,
- 'EXEC_STMT': -3,
'BUILD_CLASS': -2,
'STORE_NAME': -1,
'STORE_ATTR': -2,
diff --git a/Lib/compiler/pycodegen.py b/Lib/compiler/pycodegen.py
index af99045..e0c3a10 100644
--- a/Lib/compiler/pycodegen.py
+++ b/Lib/compiler/pycodegen.py
@@ -1043,18 +1043,6 @@ class CodeGenerator:
self.emit('ROT_THREE')
self.emit('STORE_SUBSCR')
- def visitExec(self, node):
- self.visit(node.expr)
- if node.locals is None:
- self.emit('LOAD_CONST', None)
- else:
- self.visit(node.locals)
- if node.globals is None:
- self.emit('DUP_TOP')
- else:
- self.visit(node.globals)
- self.emit('EXEC_STMT')
-
def visitCallFunc(self, node):
pos = 0
kw = 0
diff --git a/Lib/compiler/transformer.py b/Lib/compiler/transformer.py
index a9b971a..4f2107f 100644
--- a/Lib/compiler/transformer.py
+++ b/Lib/compiler/transformer.py
@@ -468,20 +468,6 @@ class Transformer:
names.append(nodelist[i][1])
return Global(names, lineno=nodelist[0][2])
- def exec_stmt(self, nodelist):
- # exec_stmt: 'exec' expr ['in' expr [',' expr]]
- expr1 = self.com_node(nodelist[1])
- if len(nodelist) >= 4:
- expr2 = self.com_node(nodelist[3])
- if len(nodelist) >= 6:
- expr3 = self.com_node(nodelist[5])
- else:
- expr3 = None
- else:
- expr2 = expr3 = None
-
- return Exec(expr1, expr2, expr3, lineno=nodelist[0][2])
-
def assert_stmt(self, nodelist):
# 'assert': test, [',' test]
expr1 = self.com_node(nodelist[1])
@@ -1429,7 +1415,6 @@ _legal_node_types = [
symbol.raise_stmt,
symbol.import_stmt,
symbol.global_stmt,
- symbol.exec_stmt,
symbol.assert_stmt,
symbol.if_stmt,
symbol.while_stmt,
diff --git a/Lib/doctest.py b/Lib/doctest.py
index bdd284a..435e13b 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -1209,8 +1209,8 @@ class DocTestRunner:
# keyboard interrupts.)
try:
# Don't blink! This is where the user's code gets run.
- exec compile(example.source, filename, "single",
- compileflags, 1) in test.globs
+ exec(compile(example.source, filename, "single",
+ compileflags, 1), test.globs)
self.debugger.set_continue() # ==== Example Finished ====
exception = None
except KeyboardInterrupt:
diff --git a/Lib/hashlib.py b/Lib/hashlib.py
index 48fc56c..789e24e 100644
--- a/Lib/hashlib.py
+++ b/Lib/hashlib.py
@@ -82,11 +82,11 @@ try:
f = getattr(_hashlib, opensslFuncName)
f()
# Use the C function directly (very fast)
- exec funcName + ' = f'
+ exec(funcName + ' = f')
except ValueError:
try:
# Use the builtin implementation directly (fast)
- exec funcName + ' = __get_builtin_constructor(funcName)'
+ exec(funcName + ' = __get_builtin_constructor(funcName)')
except ValueError:
# this one has no builtin implementation, don't define it
pass
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
index d8befff..709b3a7 100644
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -690,7 +690,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
if self.rpcclt:
self.rpcclt.remotequeue("exec", "runcode", (code,), {})
else:
- exec code in self.locals
+ exec(code, self.locals)
return 1
def runcode(self, code):
@@ -711,7 +711,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
elif debugger:
debugger.run(code, self.locals)
else:
- exec code in self.locals
+ exec(code, self.locals)
except SystemExit:
if not self.tkconsole.closing:
if tkMessageBox.askyesno(
diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py
index ae810c4..61364a5 100644
--- a/Lib/idlelib/run.py
+++ b/Lib/idlelib/run.py
@@ -282,7 +282,7 @@ class Executive(object):
def runcode(self, code):
try:
self.usr_exc_info = None
- exec code in self.locals
+ exec(code, self.locals)
except:
self.usr_exc_info = sys.exc_info()
if quitting:
diff --git a/Lib/ihooks.py b/Lib/ihooks.py
index f5b93ab..eef3474 100644
--- a/Lib/ihooks.py
+++ b/Lib/ihooks.py
@@ -323,7 +323,7 @@ class FancyModuleLoader(ModuleLoader):
m.__path__ = path
m.__file__ = filename
try:
- exec code in m.__dict__
+ exec(code, m.__dict__)
except:
d = self.hooks.modules_dict()
if name in d:
diff --git a/Lib/imputil.py b/Lib/imputil.py
index 8a49bb1..f2e752c 100644
--- a/Lib/imputil.py
+++ b/Lib/imputil.py
@@ -301,7 +301,7 @@ class Importer:
# execute the code within the module's namespace
if not is_module:
try:
- exec code in module.__dict__
+ exec(code, module.__dict__)
except:
if fqname in sys.modules:
del sys.modules[fqname]
diff --git a/Lib/keyword.py b/Lib/keyword.py
index cd1d55e..d2b26a7 100755
--- a/Lib/keyword.py
+++ b/Lib/keyword.py
@@ -25,7 +25,6 @@ kwlist = [
'elif',
'else',
'except',
- 'exec',
'finally',
'for',
'from',
diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py
index 262c45c..bea130c 100644
--- a/Lib/lib-tk/Tkinter.py
+++ b/Lib/lib-tk/Tkinter.py
@@ -1699,7 +1699,7 @@ class Tk(Misc, Wm):
base_tcl = os.path.join(home, '.%s.tcl' % baseName)
base_py = os.path.join(home, '.%s.py' % baseName)
dir = {'self': self}
- exec 'from Tkinter import *' in dir
+ exec('from Tkinter import *', dir)
if os.path.isfile(class_tcl):
self.tk.call('source', class_tcl)
if os.path.isfile(class_py):
diff --git a/Lib/opcode.py b/Lib/opcode.py
index cf8d909..908dba4 100644
--- a/Lib/opcode.py
+++ b/Lib/opcode.py
@@ -114,7 +114,6 @@ def_op('WITH_CLEANUP', 81)
def_op('LOAD_LOCALS', 82)
def_op('RETURN_VALUE', 83)
def_op('IMPORT_STAR', 84)
-def_op('EXEC_STMT', 85)
def_op('YIELD_VALUE', 86)
def_op('POP_BLOCK', 87)
def_op('END_FINALLY', 88)
diff --git a/Lib/pdb.py b/Lib/pdb.py
index 06181e7..2bc836f 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -198,7 +198,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
globals = self.curframe.f_globals
try:
code = compile(line + '\n', '<stdin>', 'single')
- exec code in globals, locals
+ exec(code, globals, locals)
except:
t, v = sys.exc_info()[:2]
if type(t) == type(''):
diff --git a/Lib/plat-irix5/flp.py b/Lib/plat-irix5/flp.py
index 4f9175f..83a22b6 100755
--- a/Lib/plat-irix5/flp.py
+++ b/Lib/plat-irix5/flp.py
@@ -329,7 +329,7 @@ def _parse_object(file):
#
def create_full_form(inst, (fdata, odatalist)):
form = create_form(fdata)
- exec 'inst.'+fdata.Name+' = form\n'
+ exec('inst.'+fdata.Name+' = form\n')
for odata in odatalist:
create_object_instance(inst, form, odata)
@@ -338,7 +338,7 @@ def create_full_form(inst, (fdata, odatalist)):
# variable.
#
def merge_full_form(inst, form, (fdata, odatalist)):
- exec 'inst.'+fdata.Name+' = form\n'
+ exec('inst.'+fdata.Name+' = form\n')
if odatalist[0].Class != FL.BOX:
raise error, 'merge_full_form() expects FL.BOX as first obj'
for odata in odatalist[1:]:
@@ -374,7 +374,7 @@ def create_object_instance(inst, form, odata):
cbfunc = eval('inst.'+odata.Callback)
obj.set_call_back(cbfunc, odata.Argument)
if odata.Name:
- exec 'inst.' + odata.Name + ' = obj\n'
+ exec('inst.' + odata.Name + ' = obj\n')
#
# Internal _create_object: Create the object and fill options
#
diff --git a/Lib/plat-irix5/panel.py b/Lib/plat-irix5/panel.py
index 12e62a5..1be9146 100755
--- a/Lib/plat-irix5/panel.py
+++ b/Lib/plat-irix5/panel.py
@@ -130,7 +130,7 @@ def assign_members(target, attrlist, exclist, prefix):
stmt = lhs + '=' + repr(value)
if debug: print 'exec', stmt
try:
- exec stmt + '\n'
+ exec(stmt + '\n')
except KeyboardInterrupt: # Don't catch this!
raise KeyboardInterrupt
except:
@@ -186,7 +186,7 @@ def build_subactuators(panel, super_act, al):
if name:
stmt = 'panel.' + name + ' = act'
if debug: print 'exec', stmt
- exec stmt + '\n'
+ exec(stmt + '\n')
if is_endgroup(a):
panel.endgroup()
sub_al = getattrlist(a, 'al')
@@ -236,7 +236,7 @@ def build_panel(descr):
act.addact(panel)
if name:
stmt = 'panel.' + name + ' = act'
- exec stmt + '\n'
+ exec(stmt + '\n')
if is_endgroup(a):
panel.endgroup()
sub_al = getattrlist(a, 'al')
diff --git a/Lib/plat-irix6/flp.py b/Lib/plat-irix6/flp.py
index f745472..b021622 100644
--- a/Lib/plat-irix6/flp.py
+++ b/Lib/plat-irix6/flp.py
@@ -328,7 +328,7 @@ def _parse_object(file):
#
def create_full_form(inst, (fdata, odatalist)):
form = create_form(fdata)
- exec 'inst.'+fdata.Name+' = form\n'
+ exec('inst.'+fdata.Name+' = form\n')
for odata in odatalist:
create_object_instance(inst, form, odata)
@@ -337,7 +337,7 @@ def create_full_form(inst, (fdata, odatalist)):
# variable.
#
def merge_full_form(inst, form, (fdata, odatalist)):
- exec 'inst.'+fdata.Name+' = form\n'
+ exec('inst.'+fdata.Name+' = form\n')
if odatalist[0].Class != FL.BOX:
raise error, 'merge_full_form() expects FL.BOX as first obj'
for odata in odatalist[1:]:
@@ -373,7 +373,7 @@ def create_object_instance(inst, form, odata):
cbfunc = eval('inst.'+odata.Callback)
obj.set_call_back(cbfunc, odata.Argument)
if odata.Name:
- exec 'inst.' + odata.Name + ' = obj\n'
+ exec('inst.' + odata.Name + ' = obj\n')
#
# Internal _create_object: Create the object and fill options
#
diff --git a/Lib/plat-irix6/panel.py b/Lib/plat-irix6/panel.py
index 12e62a5..1be9146 100644
--- a/Lib/plat-irix6/panel.py
+++ b/Lib/plat-irix6/panel.py
@@ -130,7 +130,7 @@ def assign_members(target, attrlist, exclist, prefix):
stmt = lhs + '=' + repr(value)
if debug: print 'exec', stmt
try:
- exec stmt + '\n'
+ exec(stmt + '\n')
except KeyboardInterrupt: # Don't catch this!
raise KeyboardInterrupt
except:
@@ -186,7 +186,7 @@ def build_subactuators(panel, super_act, al):
if name:
stmt = 'panel.' + name + ' = act'
if debug: print 'exec', stmt
- exec stmt + '\n'
+ exec(stmt + '\n')
if is_endgroup(a):
panel.endgroup()
sub_al = getattrlist(a, 'al')
@@ -236,7 +236,7 @@ def build_panel(descr):
act.addact(panel)
if name:
stmt = 'panel.' + name + ' = act'
- exec stmt + '\n'
+ exec(stmt + '\n')
if is_endgroup(a):
panel.endgroup()
sub_al = getattrlist(a, 'al')
diff --git a/Lib/plat-mac/aetypes.py b/Lib/plat-mac/aetypes.py
index e5781efd..14e48d6 100644
--- a/Lib/plat-mac/aetypes.py
+++ b/Lib/plat-mac/aetypes.py
@@ -557,12 +557,12 @@ template = """
class %s(ComponentItem): want = '%s'
"""
-exec template % ("Text", 'text')
-exec template % ("Character", 'cha ')
-exec template % ("Word", 'cwor')
-exec template % ("Line", 'clin')
-exec template % ("paragraph", 'cpar')
-exec template % ("Window", 'cwin')
-exec template % ("Document", 'docu')
-exec template % ("File", 'file')
-exec template % ("InsertionPoint", 'cins')
+exec(template % ("Text", 'text'))
+exec(template % ("Character", 'cha '))
+exec(template % ("Word", 'cwor'))
+exec(template % ("Line", 'clin'))
+exec(template % ("paragraph", 'cpar'))
+exec(template % ("Window", 'cwin'))
+exec(template % ("Document", 'docu'))
+exec(template % ("File", 'file'))
+exec(template % ("InsertionPoint", 'cins'))
diff --git a/Lib/plat-mac/appletrawmain.py b/Lib/plat-mac/appletrawmain.py
index 1be9187..6f2eacb 100644
--- a/Lib/plat-mac/appletrawmain.py
+++ b/Lib/plat-mac/appletrawmain.py
@@ -57,7 +57,7 @@ else:
# funny) and go.
#
del argvemulator, os, sys, marshal, _dir, _fp
- exec __code__
+ exec(__code__)
else:
sys.stderr.write("%s: neither __main__.py nor __main__.pyc found\n"%sys.argv[0])
sys.exit(1)
diff --git a/Lib/plat-mac/pimp.py b/Lib/plat-mac/pimp.py
index 454e4b1..ff696b1 100644
--- a/Lib/plat-mac/pimp.py
+++ b/Lib/plat-mac/pimp.py
@@ -588,7 +588,7 @@ class PimpPackage:
}
installTest = self._dict['Install-test'].strip() + '\n'
try:
- exec installTest in namespace
+ exec(installTest, namespace)
except ImportError, arg:
return "no", str(arg)
except _scriptExc_NotInstalled, arg:
@@ -757,7 +757,7 @@ class PimpPackage:
if line[0] == '#':
continue
if line[:6] == 'import':
- exec line
+ exec(line)
continue
if line[-1] == '\n':
line = line[:-1]
diff --git a/Lib/profile.py b/Lib/profile.py
index 27d68ba..dc278dd 100755
--- a/Lib/profile.py
+++ b/Lib/profile.py
@@ -459,7 +459,7 @@ class Profile:
self.set_cmd(cmd)
sys.setprofile(self.dispatcher)
try:
- exec cmd in globals, locals
+ exec(cmd, globals, locals)
finally:
sys.setprofile(None)
return self
diff --git a/Lib/rexec.py b/Lib/rexec.py
index 10e4bc0..37dff62 100644
--- a/Lib/rexec.py
+++ b/Lib/rexec.py
@@ -58,7 +58,7 @@ class FileDelegate(FileBase):
self.name = name
for m in FileBase.ok_file_methods + ('close',):
- exec TEMPLATE % (m, m)
+ exec(TEMPLATE % (m, m))
class RHooks(ihooks.Hooks):
@@ -310,7 +310,7 @@ class RExec(ihooks._Verbose):
"""
m = self.add_module('__main__')
- exec code in m.__dict__
+ exec(code, m.__dict__)
def r_eval(self, code):
"""Evaluate code within a restricted environment.
diff --git a/Lib/runpy.py b/Lib/runpy.py
index 8290dfe..dc350cf 100755
--- a/Lib/runpy.py
+++ b/Lib/runpy.py
@@ -29,7 +29,7 @@ def _run_code(code, run_globals, init_globals,
run_globals.update(__name__ = mod_name,
__file__ = mod_fname,
__loader__ = mod_loader)
- exec code in run_globals
+ exec(code, run_globals)
return run_globals
def _run_module_code(code, init_globals=None,
diff --git a/Lib/site.py b/Lib/site.py
index 0cf19cd..1513818 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -135,7 +135,7 @@ def addpackage(sitedir, name, known_paths):
if line.startswith("#"):
continue
if line.startswith("import"):
- exec line
+ exec(line)
continue
line = line.rstrip()
dir, dircase = makepath(sitedir, line)
diff --git a/Lib/socket.py b/Lib/socket.py
index 52fb8e3..08605f8 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -191,7 +191,7 @@ class _socketobject(object):
_s = ("def %s(self, *args): return self._sock.%s(*args)\n\n"
"%s.__doc__ = _realsocket.%s.__doc__\n")
for _m in _socketmethods:
- exec _s % (_m, _m, _m, _m)
+ exec(_s % (_m, _m, _m, _m))
del _m, _s
socket = SocketType = _socketobject
diff --git a/Lib/symbol.py b/Lib/symbol.py
index c650138..a7f7a85 100755
--- a/Lib/symbol.py
+++ b/Lib/symbol.py
@@ -43,57 +43,56 @@ import_as_names = 285
dotted_as_names = 286
dotted_name = 287
global_stmt = 288
-exec_stmt = 289
-assert_stmt = 290
-compound_stmt = 291
-if_stmt = 292
-while_stmt = 293
-for_stmt = 294
-try_stmt = 295
-with_stmt = 296
-with_var = 297
-except_clause = 298
-suite = 299
-testlist_safe = 300
-old_test = 301
-old_lambdef = 302
-test = 303
-or_test = 304
-and_test = 305
-not_test = 306
-comparison = 307
-comp_op = 308
-expr = 309
-xor_expr = 310
-and_expr = 311
-shift_expr = 312
-arith_expr = 313
-term = 314
-factor = 315
-power = 316
-atom = 317
-listmaker = 318
-testlist_gexp = 319
-lambdef = 320
-trailer = 321
-subscriptlist = 322
-subscript = 323
-sliceop = 324
-exprlist = 325
-testlist = 326
-dictmaker = 327
-classdef = 328
-arglist = 329
-argument = 330
-list_iter = 331
-list_for = 332
-list_if = 333
-gen_iter = 334
-gen_for = 335
-gen_if = 336
-testlist1 = 337
-encoding_decl = 338
-yield_expr = 339
+assert_stmt = 289
+compound_stmt = 290
+if_stmt = 291
+while_stmt = 292
+for_stmt = 293
+try_stmt = 294
+with_stmt = 295
+with_var = 296
+except_clause = 297
+suite = 298
+testlist_safe = 299
+old_test = 300
+old_lambdef = 301
+test = 302
+or_test = 303
+and_test = 304
+not_test = 305
+comparison = 306
+comp_op = 307
+expr = 308
+xor_expr = 309
+and_expr = 310
+shift_expr = 311
+arith_expr = 312
+term = 313
+factor = 314
+power = 315
+atom = 316
+listmaker = 317
+testlist_gexp = 318
+lambdef = 319
+trailer = 320
+subscriptlist = 321
+subscript = 322
+sliceop = 323
+exprlist = 324
+testlist = 325
+dictsetmaker = 326
+classdef = 327
+arglist = 328
+argument = 329
+list_iter = 330
+list_for = 331
+list_if = 332
+gen_iter = 333
+gen_for = 334
+gen_if = 335
+testlist1 = 336
+encoding_decl = 337
+yield_expr = 338
#--end constants--
sym_name = {}
diff --git a/Lib/test/crashers/bogus_code_obj.py b/Lib/test/crashers/bogus_code_obj.py
index 613ae51..43815c1 100644
--- a/Lib/test/crashers/bogus_code_obj.py
+++ b/Lib/test/crashers/bogus_code_obj.py
@@ -16,4 +16,4 @@ import types
co = types.CodeType(0, 0, 0, 0, '\x04\x71\x00\x00', (),
(), (), '', '', 1, '')
-exec co
+exec(co)
diff --git a/Lib/test/output/test_cProfile b/Lib/test/output/test_cProfile
index fff3568..f9483a3 100644
--- a/Lib/test/output/test_cProfile
+++ b/Lib/test/output/test_cProfile
@@ -1,5 +1,5 @@
test_cProfile
- 126 function calls (106 primitive calls) in 1.000 CPU seconds
+ 127 function calls (107 primitive calls) in 1.000 CPU seconds
Ordered by: standard name
@@ -14,6 +14,7 @@ test_cProfile
4 0.116 0.029 0.120 0.030 test_cProfile.py:78(helper1)
2 0.000 0.000 0.140 0.070 test_cProfile.py:89(helper2_indirect)
8 0.312 0.039 0.400 0.050 test_cProfile.py:93(helper2)
+ 1 0.000 0.000 1.000 1.000 {exec}
12 0.000 0.000 0.012 0.001 {hasattr}
4 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects}
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
@@ -44,6 +45,7 @@ test_cProfile.py:89(helper2_indirect) -> 2 0.006 0.040
2 0.078 0.100 test_cProfile.py:93(helper2)
test_cProfile.py:93(helper2) -> 8 0.064 0.080 test_cProfile.py:103(subhelper)
8 0.000 0.008 {hasattr}
+{exec} -> 1 0.000 1.000 <string>:1(<module>)
{hasattr} -> 12 0.012 0.012 test_cProfile.py:115(__getattr__)
{method 'append' of 'list' objects} ->
{method 'disable' of '_lsprof.Profiler' objects} ->
@@ -55,7 +57,7 @@ test_cProfile.py:93(helper2) -> 8 0.064 0.080
Function was called by...
ncalls tottime cumtime
-<string>:1(<module>) <-
+<string>:1(<module>) <- 1 0.000 1.000 {exec}
test_cProfile.py:103(subhelper) <- 8 0.064 0.080 test_cProfile.py:93(helper2)
test_cProfile.py:115(__getattr__) <- 16 0.016 0.016 test_cProfile.py:103(subhelper)
12 0.012 0.012 {hasattr}
@@ -69,6 +71,7 @@ test_cProfile.py:78(helper1) <- 4 0.116 0.120
test_cProfile.py:89(helper2_indirect) <- 2 0.000 0.140 test_cProfile.py:60(helper)
test_cProfile.py:93(helper2) <- 6 0.234 0.300 test_cProfile.py:60(helper)
2 0.078 0.100 test_cProfile.py:89(helper2_indirect)
+{exec} <-
{hasattr} <- 4 0.000 0.004 test_cProfile.py:78(helper1)
8 0.000 0.008 test_cProfile.py:93(helper2)
{method 'append' of 'list' objects} <- 4 0.000 0.000 test_cProfile.py:78(helper1)
diff --git a/Lib/test/output/test_grammar b/Lib/test/output/test_grammar
index 4fa9cb0..8be2a1f 100644
--- a/Lib/test/output/test_grammar
+++ b/Lib/test/output/test_grammar
@@ -39,7 +39,6 @@ raise_stmt
import_name
import_from
global_stmt
-exec_stmt
assert_stmt
if_stmt
while_stmt
diff --git a/Lib/test/output/test_profile b/Lib/test/output/test_profile
index 96bd77f..14bd9ac 100644
--- a/Lib/test/output/test_profile
+++ b/Lib/test/output/test_profile
@@ -1,11 +1,12 @@
test_profile
- 127 function calls (107 primitive calls) in 1.000 CPU seconds
+ 128 function calls (108 primitive calls) in 1.000 CPU seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
4 0.000 0.000 0.000 0.000 :0(append)
4 0.000 0.000 0.000 0.000 :0(exc_info)
+ 1 0.000 0.000 1.000 1.000 :0(exec)
12 0.000 0.000 0.012 0.001 :0(hasattr)
8 0.000 0.000 0.000 0.000 :0(range)
1 0.000 0.000 0.000 0.000 :0(setprofile)
@@ -28,13 +29,14 @@ test_profile
Function called...
:0(append) ->
:0(exc_info) ->
+:0(exec) -> <string>:1(<module>)(1) 1.000
:0(hasattr) -> test_profile.py:115(__getattr__)(12) 0.028
:0(range) ->
:0(setprofile) ->
<string>:1(<module>) -> test_profile.py:30(testfunc)(1) 1.000
profile:0(profiler) -> profile:0(testfunc())(1) 1.000
-profile:0(testfunc()) -> :0(setprofile)(1) 0.000
- <string>:1(<module>)(1) 1.000
+profile:0(testfunc()) -> :0(exec)(1) 1.000
+ :0(setprofile)(1) 0.000
test_profile.py:103(subhelper) -> :0(range)(8) 0.000
test_profile.py:115(__getattr__)(16) 0.028
test_profile.py:115(__getattr__) ->
@@ -60,11 +62,12 @@ test_profile.py:93(helper2) -> :0(hasattr)(8) 0.012
Function was called by...
:0(append) <- test_profile.py:78(helper1)(4) 0.120
:0(exc_info) <- test_profile.py:78(helper1)(4) 0.120
+:0(exec) <- profile:0(testfunc())(1) 1.000
:0(hasattr) <- test_profile.py:78(helper1)(4) 0.120
test_profile.py:93(helper2)(8) 0.400
:0(range) <- test_profile.py:103(subhelper)(8) 0.080
:0(setprofile) <- profile:0(testfunc())(1) 1.000
-<string>:1(<module>) <- profile:0(testfunc())(1) 1.000
+<string>:1(<module>) <- :0(exec)(1) 1.000
profile:0(profiler) <-
profile:0(testfunc()) <- profile:0(profiler)(1) 0.000
test_profile.py:103(subhelper) <- test_profile.py:93(helper2)(8) 0.400
diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py
index dba9161..e4f0f44 100644
--- a/Lib/test/test___all__.py
+++ b/Lib/test/test___all__.py
@@ -15,7 +15,7 @@ class AllTest(unittest.TestCase):
def check_all(self, modname):
names = {}
try:
- exec "import %s" % modname in names
+ exec("import %s" % modname, names)
except ImportError:
# Silent fail here seems the best route since some modules
# may not be available in all environments.
@@ -23,7 +23,7 @@ class AllTest(unittest.TestCase):
verify(hasattr(sys.modules[modname], "__all__"),
"%s has no __all__ attribute" % modname)
names = {}
- exec "from %s import *" % modname in names
+ exec("from %s import *" % modname, names)
if "__builtins__" in names:
del names["__builtins__"]
keys = set(names)
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
index 80e8d78..f1df3eb 100644
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -50,8 +50,6 @@ exec_tests = [
"import sys",
# ImportFrom
"from sys import v",
- # Exec
- "exec 'v'",
# Global
"global v",
# Expr
@@ -169,7 +167,6 @@ exec_results = [
('Module', [('Assert', (1, 0), ('Name', (1, 7), 'v', ('Load',)), None)]),
('Module', [('Import', (1, 0), [('alias', 'sys', None)])]),
('Module', [('ImportFrom', (1, 0), 'sys', [('alias', 'v', None)], 0)]),
-('Module', [('Exec', (1, 0), ('Str', (1, 5), 'v'), None, None)]),
('Module', [('Global', (1, 0), ['v'])]),
('Module', [('Expr', (1, 0), ('Num', (1, 0), 1))]),
('Module', [('Pass', (1, 0))]),
diff --git a/Lib/test/test_binop.py b/Lib/test/test_binop.py
index 719186b..ccce207 100644
--- a/Lib/test/test_binop.py
+++ b/Lib/test/test_binop.py
@@ -302,7 +302,7 @@ class RatTestCase(unittest.TestCase):
self.assertEqual(10.0, Rat(10))
def test_future_div(self):
- exec future_test
+ exec(future_test)
# XXX Ran out of steam; TO DO: divmod, div, future division
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index d4605e1..272af86 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -395,6 +395,29 @@ class BuiltinTest(unittest.TestCase):
self.assertRaises(IOError, execfile, os.curdir)
self.assertRaises(IOError, execfile, "I_dont_exist")
+ def test_exec(self):
+ g = {}
+ exec('z = 1', g)
+ if '__builtins__' in g:
+ del g['__builtins__']
+ self.assertEqual(g, {'z': 1})
+
+ exec(u'z = 1+1', g)
+ if '__builtins__' in g:
+ del g['__builtins__']
+ self.assertEqual(g, {'z': 2})
+ g = {}
+ l = {}
+
+ import warnings
+ warnings.filterwarnings("ignore", "global statement", module="<string>")
+ exec('global a; a = 1; b = 2', g, l)
+ if '__builtins__' in g:
+ del g['__builtins__']
+ if '__builtins__' in l:
+ del l['__builtins__']
+ self.assertEqual((g, l), ({'a': 1}, {'b': 2}))
+
def test_filter(self):
self.assertEqual(filter(lambda c: 'a' <= c <= 'z', 'Hello World'), 'elloorld')
self.assertEqual(filter(None, [1, 'hello', [], [3], '', None, 9, 0]), [1, 'hello', [3], 9])
@@ -1172,7 +1195,7 @@ class BuiltinTest(unittest.TestCase):
"max(1, 2, key=1)", # keyfunc is not callable
):
try:
- exec(stmt) in globals()
+ exec(stmt, globals())
except TypeError:
pass
else:
@@ -1218,7 +1241,7 @@ class BuiltinTest(unittest.TestCase):
"min(1, 2, key=1)", # keyfunc is not callable
):
try:
- exec(stmt) in globals()
+ exec(stmt, globals())
except TypeError:
pass
else:
diff --git a/Lib/test/test_class.py b/Lib/test/test_class.py
index 795acd9..f33462a 100644
--- a/Lib/test/test_class.py
+++ b/Lib/test/test_class.py
@@ -136,7 +136,7 @@ def __%(method)s__(self, *args):
d = {}
for method in testmeths:
- exec method_template % locals() in d
+ exec(method_template % locals(), d)
for k in d:
setattr(AllTests, k, d[k])
del d, k
@@ -291,7 +291,7 @@ def check_exc(stmt, exception):
"""Raise TestFailed if executing 'stmt' does not raise 'exception'
"""
try:
- exec stmt
+ exec(stmt)
except exception:
pass
else:
diff --git a/Lib/test/test_codeop.py b/Lib/test/test_codeop.py
index 5d06f2c..38a192b 100644
--- a/Lib/test/test_codeop.py
+++ b/Lib/test/test_codeop.py
@@ -29,8 +29,8 @@ class CodeopTests(unittest.TestCase):
saved_stdout = sys.stdout
sys.stdout = cStringIO.StringIO()
try:
- exec code in d
- exec compile(str,"<input>","single") in r
+ exec(code, d)
+ exec(compile(str,"<input>","single"), r)
finally:
sys.stdout = saved_stdout
elif symbol == 'eval':
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index a3f15bf..73ef2d4 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -19,17 +19,17 @@ class TestSpecifics(unittest.TestCase):
self.assertRaises(SyntaxError, eval, 'lambda a,a=1:0')
self.assertRaises(SyntaxError, eval, 'lambda a=1,a=1:0')
try:
- exec 'def f(a, a): pass'
+ exec('def f(a, a): pass')
self.fail("duplicate arguments")
except SyntaxError:
pass
try:
- exec 'def f(a = 0, a = 1): pass'
+ exec('def f(a = 0, a = 1): pass')
self.fail("duplicate keyword arguments")
except SyntaxError:
pass
try:
- exec 'def f(a): global a; a = 1'
+ exec('def f(a): global a; a = 1')
self.fail("variable is global and local")
except SyntaxError:
pass
@@ -39,7 +39,7 @@ class TestSpecifics(unittest.TestCase):
def test_duplicate_global_local(self):
try:
- exec 'def f(a): global a; a = 1'
+ exec('def f(a): global a; a = 1')
self.fail("variable is global and local")
except SyntaxError:
pass
@@ -59,22 +59,22 @@ class TestSpecifics(unittest.TestCase):
m = M()
g = globals()
- exec 'z = a' in g, m
+ exec('z = a', g, m)
self.assertEqual(m.results, ('z', 12))
try:
- exec 'z = b' in g, m
+ exec('z = b', g, m)
except NameError:
pass
else:
self.fail('Did not detect a KeyError')
- exec 'z = dir()' in g, m
+ exec('z = dir()', g, m)
self.assertEqual(m.results, ('z', list('xyz')))
- exec 'z = globals()' in g, m
+ exec('z = globals()', g, m)
self.assertEqual(m.results, ('z', g))
- exec 'z = locals()' in g, m
+ exec('z = locals()', g, m)
self.assertEqual(m.results, ('z', m))
try:
- exec 'z = b' in m
+ exec('z = b', m)
except TypeError:
pass
else:
@@ -85,7 +85,7 @@ class TestSpecifics(unittest.TestCase):
pass
m = A()
try:
- exec 'z = a' in g, m
+ exec('z = a', g, m)
except TypeError:
pass
else:
@@ -98,11 +98,12 @@ class TestSpecifics(unittest.TestCase):
return 12
return dict.__getitem__(self, key)
d = D()
- exec 'z = a' in g, d
+ exec('z = a', g, d)
self.assertEqual(d['z'], 12)
def test_extended_arg(self):
longexpr = 'x = x or ' + '-x' * 2500
+ g = {}
code = '''
def f(x):
%s
@@ -121,8 +122,8 @@ def f(x):
# EXTENDED_ARG/JUMP_ABSOLUTE here
return x
''' % ((longexpr,)*10)
- exec code
- self.assertEqual(f(5), 0)
+ exec(code, g)
+ self.assertEqual(g['f'](5), 0)
def test_complex_args(self):
@@ -146,7 +147,7 @@ def f(x):
def test_argument_order(self):
try:
- exec 'def f(a=1, (b, c)): pass'
+ exec('def f(a=1, (b, c)): pass')
self.fail("non-default args after default")
except SyntaxError:
pass
diff --git a/Lib/test/test_compiler.py b/Lib/test/test_compiler.py
index 81f2ea8..783a34c 100644
--- a/Lib/test/test_compiler.py
+++ b/Lib/test/test_compiler.py
@@ -61,7 +61,7 @@ class CompilerTest(unittest.TestCase):
c = compiler.compile("try:\n 1/0\nexcept:\n e = 1\nfinally:\n f = 1",
"<string>", "exec")
dct = {}
- exec c in dct
+ exec(c, dct)
self.assertEquals(dct.get('e'), 1)
self.assertEquals(dct.get('f'), 1)
@@ -73,7 +73,7 @@ class CompilerTest(unittest.TestCase):
self.assert_('__doc__' in c.co_names)
c = compiler.compile('def f():\n "doc"', '<string>', 'exec')
g = {}
- exec c in g
+ exec(c, g)
self.assertEquals(g['f'].__doc__, "doc")
def testLineNo(self):
@@ -113,7 +113,7 @@ class CompilerTest(unittest.TestCase):
'<string>',
'exec')
dct = {}
- exec c in dct
+ exec(c, dct)
self.assertEquals(dct.get('result'), 3)
def testGenExp(self):
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 53054ad..b2e7e66 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -55,7 +55,7 @@ def testternop(a, b, c, res, expr="a[b:c]", meth="__getslice__"):
def testsetop(a, b, res, stmt="a+=b", meth="__iadd__"):
if verbose: print "checking", stmt
dict = {'a': deepcopy(a), 'b': b}
- exec stmt in dict
+ exec(stmt, dict)
vereq(dict['a'], res)
t = type(a)
m = getattr(t, meth)
@@ -73,7 +73,7 @@ def testsetop(a, b, res, stmt="a+=b", meth="__iadd__"):
def testset2op(a, b, c, res, stmt="a[b]=c", meth="__setitem__"):
if verbose: print "checking", stmt
dict = {'a': deepcopy(a), 'b': b, 'c': c}
- exec stmt in dict
+ exec(stmt, dict)
vereq(dict['a'], res)
t = type(a)
m = getattr(t, meth)
@@ -91,7 +91,7 @@ def testset2op(a, b, c, res, stmt="a[b]=c", meth="__setitem__"):
def testset3op(a, b, c, d, res, stmt="a[b:c]=d", meth="__setslice__"):
if verbose: print "checking", stmt
dict = {'a': deepcopy(a), 'b': b, 'c': c, 'd': d}
- exec stmt in dict
+ exec(stmt, dict)
vereq(dict['a'], res)
t = type(a)
while meth not in t.__dict__:
@@ -3943,7 +3943,7 @@ def notimplemented():
def check(expr, x, y):
try:
- exec expr in {'x': x, 'y': y, 'operator': operator}
+ exec(expr, {'x': x, 'y': y, 'operator': operator})
except TypeError:
pass
else:
diff --git a/Lib/test/test_descrtut.py b/Lib/test/test_descrtut.py
index 28d7d13..aca6660 100644
--- a/Lib/test/test_descrtut.py
+++ b/Lib/test/test_descrtut.py
@@ -67,7 +67,7 @@ statement or the built-in function eval():
>>> print sorted(a.keys())
[1, 2]
- >>> exec "x = 3; print x" in a
+ >>> exec("x = 3; print x", a)
3
>>> print sorted(a.keys(), key=lambda x: (str(type(x)), x))
[1, 2, '__builtins__', 'x']
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py
index c31092c..f9a6a07 100644
--- a/Lib/test/test_dis.py
+++ b/Lib/test/test_dis.py
@@ -135,7 +135,7 @@ class DisTests(unittest.TestCase):
def func(count):
namespace = {}
func = "def foo():\n " + "".join(["\n "] * count + ["spam\n"])
- exec func in namespace
+ exec(func, namespace)
return namespace['foo']
# Test all small ranges
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index 1390e15..56c2449 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -2366,8 +2366,8 @@ def old_test4(): """
... '''>>> assert 1 < 2
... '''
... \"""
- >>> exec test_data in m1.__dict__
- >>> exec test_data in m2.__dict__
+ >>> exec(test_data, m1.__dict__)
+ >>> exec(test_data, m2.__dict__)
>>> m1.__dict__.update({"f2": m2._f, "g2": m2.g, "h2": m2.H})
Tests that objects outside m1 are excluded:
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index 0eb6b46..b5c5676 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -87,7 +87,7 @@ class ExceptionTests(unittest.TestCase):
self.raise_catch(RuntimeError, "RuntimeError")
self.raise_catch(SyntaxError, "SyntaxError")
- try: exec '/\n'
+ try: exec('/\n')
except SyntaxError: pass
self.raise_catch(IndentationError, "IndentationError")
diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py
index ab33528..930c851 100644
--- a/Lib/test/test_funcattrs.py
+++ b/Lib/test/test_funcattrs.py
@@ -278,7 +278,7 @@ def test_func_name():
cantset(f, "__name__", 1)
# test that you can access func.__name__ in restricted mode
s = """def f(): pass\nf.__name__"""
- exec s in {'__builtins__':{}}
+ exec(s, {'__builtins__':{}})
def test_func_code():
diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py
index ec470c4..675b988 100644
--- a/Lib/test/test_gc.py
+++ b/Lib/test/test_gc.py
@@ -153,7 +153,7 @@ def test_function():
# Tricky: f -> d -> f, code should call d.clear() after the exec to
# break the cycle.
d = {}
- exec("def f(): pass\n") in d
+ exec("def f(): pass\n", d)
gc.collect()
del d
expect(gc.collect(), 2, "function")
diff --git a/Lib/test/test_getopt.py b/Lib/test/test_getopt.py
index 9856a6a..f565d23 100644
--- a/Lib/test/test_getopt.py
+++ b/Lib/test/test_getopt.py
@@ -10,7 +10,7 @@ def expectException(teststr, expected, failure=AssertionError):
"""Executes a statement passed in teststr, and raises an exception
(failure) if the expected exception is *not* raised."""
try:
- exec teststr
+ exec(teststr)
except expected:
pass
else:
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 93dc9ec..6e9b204 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -449,42 +449,6 @@ def f():
global a, b
global one, two, three, four, five, six, seven, eight, nine, ten
-print 'exec_stmt' # 'exec' expr ['in' expr [',' expr]]
-def f():
- z = None
- del z
- exec 'z=1+1\n'
- if z != 2: raise TestFailed, 'exec \'z=1+1\'\\n'
- del z
- exec 'z=1+1'
- if z != 2: raise TestFailed, 'exec \'z=1+1\''
- z = None
- del z
- import types
- if hasattr(types, "UnicodeType"):
- exec r"""if 1:
- exec u'z=1+1\n'
- if z != 2: raise TestFailed, 'exec u\'z=1+1\'\\n'
- del z
- exec u'z=1+1'
- if z != 2: raise TestFailed, 'exec u\'z=1+1\''
-"""
-f()
-g = {}
-exec 'z = 1' in g
-if '__builtins__' in g: del g['__builtins__']
-if g != {'z': 1}: raise TestFailed, 'exec \'z = 1\' in g'
-g = {}
-l = {}
-
-import warnings
-warnings.filterwarnings("ignore", "global statement", module="<string>")
-exec 'global a; a = 1; b = 2' in g, l
-if '__builtins__' in g: del g['__builtins__']
-if '__builtins__' in l: del l['__builtins__']
-if (g, l) != ({'a':1}, {'b':2}): raise TestFailed, 'exec ... in g (%s), l (%s)' %(g,l)
-
-
print "assert_stmt" # assert_stmt: 'assert' test [',' test]
assert 1
assert 1, 1
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
index effba3c..b64c23b 100644
--- a/Lib/test/test_import.py
+++ b/Lib/test/test_import.py
@@ -107,7 +107,7 @@ def test_module_with_large_stack(module):
sys.path.append('')
# this used to crash
- exec 'import ' + module
+ exec('import ' + module)
# cleanup
del sys.path[-1]
diff --git a/Lib/test/test_importhooks.py b/Lib/test/test_importhooks.py
index d31bcb2..5077d98 100644
--- a/Lib/test/test_importhooks.py
+++ b/Lib/test/test_importhooks.py
@@ -81,7 +81,7 @@ class TestImporter:
mod.__loader__ = self
if ispkg:
mod.__path__ = self._get__path__()
- exec code in mod.__dict__
+ exec(code, mod.__dict__)
return mod
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 1030f97..e5946e9 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -199,7 +199,7 @@ class TestRetrievingSourceCode(GetSourceBase):
m = sys.modules[name] = module(name)
m.__file__ = "<string>" # hopefully not a real filename...
m.__loader__ = "dummy" # pretend the filename is understood by a loader
- exec "def x(): pass" in m.__dict__
+ exec("def x(): pass", m.__dict__)
self.assertEqual(inspect.getsourcefile(m.x.func_code), '<string>')
del sys.modules[name]
inspect.getmodule(compile('a=10','','single'))
diff --git a/Lib/test/test_multibytecodec.py b/Lib/test/test_multibytecodec.py
index 397ebeb..95f4b38 100644
--- a/Lib/test/test_multibytecodec.py
+++ b/Lib/test/test_multibytecodec.py
@@ -49,7 +49,7 @@ class Test_MultibyteCodec(unittest.TestCase):
try:
for enc in ALL_CJKENCODINGS:
print >> open(TESTFN, 'w'), '# coding:', enc
- exec open(TESTFN)
+ execfile(TESTFN)
finally:
os.unlink(TESTFN)
diff --git a/Lib/test/test_operations.py b/Lib/test/test_operations.py
index 67e77aa..8baef4c 100644
--- a/Lib/test/test_operations.py
+++ b/Lib/test/test_operations.py
@@ -30,7 +30,7 @@ for stmt in ['d[x2] = 2',
'd.pop(x2)',
'd.update({x2: 2})']:
try:
- exec stmt
+ exec(stmt)
except RuntimeError:
print "%s: caught the RuntimeError outside" % (stmt,)
else:
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py
index 8aa1657..96384cd 100644
--- a/Lib/test/test_parser.py
+++ b/Lib/test/test_parser.py
@@ -429,7 +429,7 @@ class CompileTestCase(unittest.TestCase):
st = parser.suite('x = 2; y = x + 3')
code = parser.compilest(st)
globs = {}
- exec code in globs
+ exec(code, globs)
self.assertEquals(globs['y'], 5)
def test_compile_error(self):
diff --git a/Lib/test/test_scope.py b/Lib/test/test_scope.py
index 98b7ef3..e4e592a 100644
--- a/Lib/test/test_scope.py
+++ b/Lib/test/test_scope.py
@@ -205,15 +205,6 @@ def unoptimized_clash2():
return f
""")
-# XXX could allow this for exec with const argument, but what's the point
-check_syntax("""\
-def error(y):
- exec "a = 1"
- def f(x):
- return x + y
- return f
-""")
-
check_syntax("""\
def f(x):
def g():
@@ -230,7 +221,7 @@ def f():
# and verify a few cases that should work
-exec """
+exec("""
def noproblem1():
from string import *
f = lambda x:x
@@ -245,7 +236,7 @@ def noproblem3():
def f(x):
global y
y = x
-"""
+""")
print "12. lambdas"
@@ -526,7 +517,7 @@ else:
print "eval() should have failed, because code contained free vars"
try:
- exec g.func_code
+ exec(g.func_code)
except TypeError:
pass
else:
diff --git a/Lib/test/test_transformer.py b/Lib/test/test_transformer.py
index 909cda5..6f1c4f9 100644
--- a/Lib/test/test_transformer.py
+++ b/Lib/test/test_transformer.py
@@ -24,7 +24,7 @@ class Tests(unittest.TestCase):
# is correct
c = compile(s, '<string>', 'single')
vals = {}
- exec c in vals
+ exec(c, vals)
assert vals['a'] == 1
assert vals['b'] == 2
diff --git a/Lib/test/time_hashlib.py b/Lib/test/time_hashlib.py
index 1bf707d..de25cfd 100644
--- a/Lib/test/time_hashlib.py
+++ b/Lib/test/time_hashlib.py
@@ -44,22 +44,22 @@ hName = sys.argv[1]
# setup our creatorFunc to test the requested hash
#
if hName in ('_md5', '_sha'):
- exec 'import '+hName
- exec 'creatorFunc = '+hName+'.new'
+ exec('import '+hName)
+ exec('creatorFunc = '+hName+'.new')
print "testing speed of old", hName, "legacy interface"
elif hName == '_hashlib' and len(sys.argv) > 3:
import _hashlib
- exec 'creatorFunc = _hashlib.%s' % sys.argv[2]
+ exec('creatorFunc = _hashlib.%s' % sys.argv[2])
print "testing speed of _hashlib.%s" % sys.argv[2], getattr(_hashlib, sys.argv[2])
elif hName == '_hashlib' and len(sys.argv) == 3:
import _hashlib
- exec 'creatorFunc = lambda x=_hashlib.new : x(%r)' % sys.argv[2]
+ exec('creatorFunc = lambda x=_hashlib.new : x(%r)' % sys.argv[2])
print "testing speed of _hashlib.new(%r)" % sys.argv[2]
elif hasattr(hashlib, hName) and callable(getattr(hashlib, hName)):
creatorFunc = getattr(hashlib, hName)
print "testing speed of hashlib."+hName, getattr(hashlib, hName)
else:
- exec "creatorFunc = lambda x=hashlib.new : x(%r)" % hName
+ exec("creatorFunc = lambda x=hashlib.new : x(%r)" % hName)
print "testing speed of hashlib.new(%r)" % hName
try:
diff --git a/Lib/timeit.py b/Lib/timeit.py
index 8c0f7a5..190b8c5 100644
--- a/Lib/timeit.py
+++ b/Lib/timeit.py
@@ -115,7 +115,7 @@ class Timer:
self.src = src # Save for traceback display
code = compile(src, dummy_src_name, "exec")
ns = {}
- exec code in globals(), ns
+ exec(code, globals(), ns)
self.inner = ns["inner"]
def print_exc(self, file=None):
diff --git a/Lib/trace.py b/Lib/trace.py
index 7ebed71..c7ed0a5 100644
--- a/Lib/trace.py
+++ b/Lib/trace.py
@@ -484,7 +484,7 @@ class Trace:
sys.settrace(self.globaltrace)
threading.settrace(self.globaltrace)
try:
- exec cmd in dict, dict
+ exec(cmd, dict, dict)
finally:
if not self.donothing:
sys.settrace(None)
@@ -497,7 +497,7 @@ class Trace:
sys.settrace(self.globaltrace)
threading.settrace(self.globaltrace)
try:
- exec cmd in globals, locals
+ exec(cmd, globals, locals)
finally:
if not self.donothing:
sys.settrace(None)
diff --git a/Misc/vgrindefs b/Misc/vgrindefs
index bc6eba1..3e6d8a4 100644
--- a/Misc/vgrindefs
+++ b/Misc/vgrindefs
@@ -6,5 +6,5 @@ python|Python|py:\
:pb=^\d?(def|class)\d\p(\d|\\|\(|\:):\
:cb=#:ce=$:sb=":se=\e":lb=':le=\e':\
:kw=assert and break class continue def del elif else except\
- exec finally for from global if import in is lambda not or\
+ finally for from global if import in is lambda not or\
pass print raise return try while yield:
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c
index 904b7dd..c90d34d 100644
--- a/Modules/parsermodule.c
+++ b/Modules/parsermodule.c
@@ -848,7 +848,7 @@ VALIDATER(raise_stmt); VALIDATER(import_stmt);
VALIDATER(import_name); VALIDATER(import_from);
VALIDATER(global_stmt); VALIDATER(list_if);
VALIDATER(assert_stmt); VALIDATER(list_for);
-VALIDATER(exec_stmt); VALIDATER(compound_stmt);
+VALIDATER(compound_stmt);
VALIDATER(while); VALIDATER(for);
VALIDATER(try); VALIDATER(except_clause);
VALIDATER(test); VALIDATER(and_test);
@@ -1465,8 +1465,7 @@ validate_small_stmt(node *tree)
|| (ntype == flow_stmt)
|| (ntype == import_stmt)
|| (ntype == global_stmt)
- || (ntype == assert_stmt)
- || (ntype == exec_stmt))
+ || (ntype == assert_stmt))
res = validate_node(CHILD(tree, 0));
else {
res = 0;
@@ -1888,32 +1887,6 @@ validate_global_stmt(node *tree)
}
-/* exec_stmt:
- *
- * 'exec' expr ['in' test [',' test]]
- */
-static int
-validate_exec_stmt(node *tree)
-{
- int nch = NCH(tree);
- int res = (validate_ntype(tree, exec_stmt)
- && ((nch == 2) || (nch == 4) || (nch == 6))
- && validate_name(CHILD(tree, 0), "exec")
- && validate_expr(CHILD(tree, 1)));
-
- if (!res && !PyErr_Occurred())
- err_string("illegal exec statement");
- if (res && (nch > 2))
- res = (validate_name(CHILD(tree, 2), "in")
- && validate_test(CHILD(tree, 3)));
- if (res && (nch == 6))
- res = (validate_comma(CHILD(tree, 4))
- && validate_test(CHILD(tree, 5)));
-
- return (res);
-}
-
-
/* assert_stmt:
*
* 'assert' test [',' test]
@@ -2914,7 +2887,7 @@ validate_node(node *tree)
case small_stmt:
/*
* expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt
- * | import_stmt | global_stmt | exec_stmt | assert_stmt
+ * | import_stmt | global_stmt | assert_stmt
*/
res = validate_small_stmt(tree);
break;
@@ -2984,9 +2957,6 @@ validate_node(node *tree)
case global_stmt:
res = validate_global_stmt(tree);
break;
- case exec_stmt:
- res = validate_exec_stmt(tree);
- break;
case assert_stmt:
res = validate_assert_stmt(tree);
break;
diff --git a/Modules/symtablemodule.c b/Modules/symtablemodule.c
index c90d765..95edfea 100644
--- a/Modules/symtablemodule.c
+++ b/Modules/symtablemodule.c
@@ -73,8 +73,7 @@ init_symtable(void)
PyModule_AddIntConstant(m, "TYPE_MODULE", ModuleBlock);
PyModule_AddIntConstant(m, "OPT_IMPORT_STAR", OPT_IMPORT_STAR);
- PyModule_AddIntConstant(m, "OPT_EXEC", OPT_EXEC);
- PyModule_AddIntConstant(m, "OPT_BARE_EXEC", OPT_BARE_EXEC);
+ PyModule_AddIntConstant(m, "OPT_TOPLEVEL", OPT_TOPLEVEL);
PyModule_AddIntConstant(m, "LOCAL", LOCAL);
PyModule_AddIntConstant(m, "GLOBAL_EXPLICIT", GLOBAL_EXPLICIT);
diff --git a/Parser/Python.asdl b/Parser/Python.asdl
index 55b3bd3..27f65b4 100644
--- a/Parser/Python.asdl
+++ b/Parser/Python.asdl
@@ -36,11 +36,6 @@ module Python version "$Revision$"
| Import(alias* names)
| ImportFrom(identifier module, alias* names, int? level)
- -- Doesn't capture requirement that locals must be
- -- defined if globals is
- -- still supports use as a function!
- | Exec(expr body, expr? globals, expr? locals)
-
| Global(identifier* names)
| Expr(expr value)
| Pass | Break | Continue
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index b322039..6ba978b 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -123,12 +123,6 @@ static char *ImportFrom_fields[]={
"names",
"level",
};
-static PyTypeObject *Exec_type;
-static char *Exec_fields[]={
- "body",
- "globals",
- "locals",
-};
static PyTypeObject *Global_type;
static char *Global_fields[]={
"names",
@@ -494,8 +488,6 @@ static int init_types(void)
ImportFrom_type = make_type("ImportFrom", stmt_type, ImportFrom_fields,
3);
if (!ImportFrom_type) return 0;
- Exec_type = make_type("Exec", stmt_type, Exec_fields, 3);
- if (!Exec_type) return 0;
Global_type = make_type("Global", stmt_type, Global_fields, 1);
if (!Global_type) return 0;
Expr_type = make_type("Expr", stmt_type, Expr_fields, 1);
@@ -1170,30 +1162,6 @@ ImportFrom(identifier module, asdl_seq * names, int level, int lineno, int
}
stmt_ty
-Exec(expr_ty body, expr_ty globals, expr_ty locals, int lineno, int col_offset,
- PyArena *arena)
-{
- stmt_ty p;
- if (!body) {
- PyErr_SetString(PyExc_ValueError,
- "field body is required for Exec");
- return NULL;
- }
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
- if (!p) {
- PyErr_NoMemory();
- return NULL;
- }
- p->kind = Exec_kind;
- p->v.Exec.body = body;
- p->v.Exec.globals = globals;
- p->v.Exec.locals = locals;
- p->lineno = lineno;
- p->col_offset = col_offset;
- return p;
-}
-
-stmt_ty
Global(asdl_seq * names, int lineno, int col_offset, PyArena *arena)
{
stmt_ty p;
@@ -2274,25 +2242,6 @@ ast2obj_stmt(void* _o)
goto failed;
Py_DECREF(value);
break;
- case Exec_kind:
- result = PyType_GenericNew(Exec_type, NULL, NULL);
- if (!result) goto failed;
- value = ast2obj_expr(o->v.Exec.body);
- if (!value) goto failed;
- if (PyObject_SetAttrString(result, "body", value) == -1)
- goto failed;
- Py_DECREF(value);
- value = ast2obj_expr(o->v.Exec.globals);
- if (!value) goto failed;
- if (PyObject_SetAttrString(result, "globals", value) == -1)
- goto failed;
- Py_DECREF(value);
- value = ast2obj_expr(o->v.Exec.locals);
- if (!value) goto failed;
- if (PyObject_SetAttrString(result, "locals", value) == -1)
- goto failed;
- Py_DECREF(value);
- break;
case Global_kind:
result = PyType_GenericNew(Global_type, NULL, NULL);
if (!result) goto failed;
@@ -3082,7 +3031,6 @@ init_ast(void)
return;
if (PyDict_SetItemString(d, "ImportFrom", (PyObject*)ImportFrom_type) <
0) return;
- if (PyDict_SetItemString(d, "Exec", (PyObject*)Exec_type) < 0) return;
if (PyDict_SetItemString(d, "Global", (PyObject*)Global_type) < 0)
return;
if (PyDict_SetItemString(d, "Expr", (PyObject*)Expr_type) < 0) return;
diff --git a/Python/ast.c b/Python/ast.c
index cd0a81d..36f706e 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -2400,37 +2400,6 @@ ast_for_global_stmt(struct compiling *c, const node *n)
}
static stmt_ty
-ast_for_exec_stmt(struct compiling *c, const node *n)
-{
- expr_ty expr1, globals = NULL, locals = NULL;
- int n_children = NCH(n);
- if (n_children != 2 && n_children != 4 && n_children != 6) {
- PyErr_Format(PyExc_SystemError,
- "poorly formed 'exec' statement: %d parts to statement",
- n_children);
- return NULL;
- }
-
- /* exec_stmt: 'exec' expr ['in' test [',' test]] */
- REQ(n, exec_stmt);
- expr1 = ast_for_expr(c, CHILD(n, 1));
- if (!expr1)
- return NULL;
- if (n_children >= 4) {
- globals = ast_for_expr(c, CHILD(n, 3));
- if (!globals)
- return NULL;
- }
- if (n_children == 6) {
- locals = ast_for_expr(c, CHILD(n, 5));
- if (!locals)
- return NULL;
- }
-
- return Exec(expr1, globals, locals, LINENO(n), n->n_col_offset, c->c_arena);
-}
-
-static stmt_ty
ast_for_assert_stmt(struct compiling *c, const node *n)
{
/* assert_stmt: 'assert' test [',' test] */
@@ -2944,8 +2913,7 @@ ast_for_stmt(struct compiling *c, const node *n)
REQ(n, small_stmt);
n = CHILD(n, 0);
/* small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt
- | flow_stmt | import_stmt | global_stmt | exec_stmt
- | assert_stmt
+ | flow_stmt | import_stmt | global_stmt | assert_stmt
*/
switch (TYPE(n)) {
case expr_stmt:
@@ -2962,8 +2930,6 @@ ast_for_stmt(struct compiling *c, const node *n)
return ast_for_import_stmt(c, n);
case global_stmt:
return ast_for_global_stmt(c, n);
- case exec_stmt:
- return ast_for_exec_stmt(c, n);
case assert_stmt:
return ast_for_assert_stmt(c, n);
default:
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 200ec26..94d4bc3 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -403,7 +403,7 @@ PyDoc_STRVAR(compile_doc,
"compile(source, filename, mode[, flags[, dont_inherit]]) -> code object\n\
\n\
Compile the source string (a Python module, statement or expression)\n\
-into a code object that can be executed by the exec statement or eval().\n\
+into a code object that can be executed by exec() or eval().\n\
The filename will be used for run-time error messages.\n\
The mode must be 'exec' to compile a module, 'single' to compile a\n\
single (interactive) statement, or 'eval' to compile an expression.\n\
@@ -543,6 +543,114 @@ The globals must be a dictionary and locals can be any mappping,\n\
defaulting to the current globals and locals.\n\
If only globals is given, locals defaults to it.\n");
+static PyObject *
+builtin_exec(PyObject *self, PyObject *args)
+{
+ PyObject *v;
+ PyObject *prog, *globals = Py_None, *locals = Py_None;
+ int plain = 0;
+
+ if (!PyArg_ParseTuple(args, "O|OO:exec", &prog, &globals, &locals))
+ return NULL;
+
+ if (globals == Py_None) {
+ globals = PyEval_GetGlobals();
+ if (locals == Py_None) {
+ locals = PyEval_GetLocals();
+ plain = 1;
+ }
+ if (!globals || !locals) {
+ PyErr_SetString(PyExc_SystemError,
+ "globals and locals cannot be NULL");
+ return NULL;
+ }
+ }
+ else if (locals == Py_None)
+ locals = globals;
+ if (!PyString_Check(prog) &&
+ !PyUnicode_Check(prog) &&
+ !PyCode_Check(prog) &&
+ !PyFile_Check(prog)) {
+ PyErr_Format(PyExc_TypeError,
+ "exec() arg 1 must be a string, file, or code "
+ "object, not %.100s", prog->ob_type->tp_name);
+ return NULL;
+ }
+ if (!PyDict_Check(globals)) {
+ PyErr_Format(PyExc_TypeError, "exec() arg 2 must be a dict, not %.100s",
+ globals->ob_type->tp_name);
+ return NULL;
+ }
+ if (!PyMapping_Check(locals)) {
+ PyErr_Format(PyExc_TypeError,
+ "arg 3 must be a mapping or None, not %.100s",
+ locals->ob_type->tp_name);
+ return NULL;
+ }
+ if (PyDict_GetItemString(globals, "__builtins__") == NULL) {
+ if (PyDict_SetItemString(globals, "__builtins__",
+ PyEval_GetBuiltins()) != 0)
+ return NULL;
+ }
+
+ if (PyCode_Check(prog)) {
+ if (PyCode_GetNumFree((PyCodeObject *)prog) > 0) {
+ PyErr_SetString(PyExc_TypeError,
+ "code object passed to exec() may not "
+ "contain free variables");
+ return NULL;
+ }
+ v = PyEval_EvalCode((PyCodeObject *) prog, globals, locals);
+ }
+ else if (PyFile_Check(prog)) {
+ FILE *fp = PyFile_AsFile(prog);
+ char *name = PyString_AsString(PyFile_Name(prog));
+ PyCompilerFlags cf;
+ cf.cf_flags = 0;
+ if (PyEval_MergeCompilerFlags(&cf))
+ v = PyRun_FileFlags(fp, name, Py_file_input, globals,
+ locals, &cf);
+ else
+ v = PyRun_File(fp, name, Py_file_input, globals,
+ locals);
+ }
+ else {
+ PyObject *tmp = NULL;
+ char *str;
+ PyCompilerFlags cf;
+ cf.cf_flags = 0;
+#ifdef Py_USING_UNICODE
+ if (PyUnicode_Check(prog)) {
+ tmp = PyUnicode_AsUTF8String(prog);
+ if (tmp == NULL)
+ return NULL;
+ prog = tmp;
+ cf.cf_flags |= PyCF_SOURCE_IS_UTF8;
+ }
+#endif
+ if (PyString_AsStringAndSize(prog, &str, NULL))
+ return NULL;
+ if (PyEval_MergeCompilerFlags(&cf))
+ v = PyRun_StringFlags(str, Py_file_input, globals,
+ locals, &cf);
+ else
+ v = PyRun_String(str, Py_file_input, globals, locals);
+ Py_XDECREF(tmp);
+ }
+ if (v == NULL)
+ return NULL;
+ Py_DECREF(v);
+ Py_RETURN_NONE;
+}
+
+PyDoc_STRVAR(exec_doc,
+"exec(object[, globals[, locals]])\n\
+\n\
+Read and execute code from a object, which can be a string, a code\n\
+object or a file object.\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_execfile(PyObject *self, PyObject *args)
@@ -1884,6 +1992,7 @@ static PyMethodDef builtin_methods[] = {
{"dir", builtin_dir, METH_VARARGS, dir_doc},
{"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},
diff --git a/Python/ceval.c b/Python/ceval.c
index 25e6a0b..dcbe53d 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -118,8 +118,6 @@ static PyObject * cmp_outcome(int, PyObject *, PyObject *);
static PyObject * import_from(PyObject *, PyObject *);
static int import_all_from(PyObject *, PyObject *);
static PyObject * build_class(PyObject *, PyObject *, PyObject *);
-static int exec_statement(PyFrameObject *,
- PyObject *, PyObject *, PyObject *);
static void set_exc_info(PyThreadState *, PyObject *, PyObject *, PyObject *);
static void reset_exc_info(PyThreadState *);
static void format_exc_check_arg(PyObject *, char *, PyObject *);
@@ -580,7 +578,6 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
It's a case-by-case judgement. I'll use intr1 for the following
cases:
- EXEC_STMT
IMPORT_STAR
IMPORT_FROM
CALL_FUNCTION (and friends)
@@ -1622,19 +1619,6 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
why = WHY_YIELD;
goto fast_yield;
- case EXEC_STMT:
- w = TOP();
- v = SECOND();
- u = THIRD();
- STACKADJ(-3);
- READ_TIMESTAMP(intr0);
- err = exec_statement(f, u, v, w);
- READ_TIMESTAMP(intr1);
- Py_DECREF(u);
- Py_DECREF(v);
- Py_DECREF(w);
- break;
-
case POP_BLOCK:
{
PyTryBlock *b = PyFrame_BlockPop(f);
@@ -4072,107 +4056,6 @@ build_class(PyObject *methods, PyObject *bases, PyObject *name)
return result;
}
-static int
-exec_statement(PyFrameObject *f, PyObject *prog, PyObject *globals,
- PyObject *locals)
-{
- int n;
- PyObject *v;
- int plain = 0;
-
- if (PyTuple_Check(prog) && globals == Py_None && locals == Py_None &&
- ((n = PyTuple_Size(prog)) == 2 || n == 3)) {
- /* Backward compatibility hack */
- globals = PyTuple_GetItem(prog, 1);
- if (n == 3)
- locals = PyTuple_GetItem(prog, 2);
- prog = PyTuple_GetItem(prog, 0);
- }
- if (globals == Py_None) {
- globals = PyEval_GetGlobals();
- if (locals == Py_None) {
- locals = PyEval_GetLocals();
- plain = 1;
- }
- if (!globals || !locals) {
- PyErr_SetString(PyExc_SystemError,
- "globals and locals cannot be NULL");
- return -1;
- }
- }
- else if (locals == Py_None)
- locals = globals;
- if (!PyString_Check(prog) &&
- !PyUnicode_Check(prog) &&
- !PyCode_Check(prog) &&
- !PyFile_Check(prog)) {
- PyErr_SetString(PyExc_TypeError,
- "exec: arg 1 must be a string, file, or code object");
- return -1;
- }
- if (!PyDict_Check(globals)) {
- PyErr_SetString(PyExc_TypeError,
- "exec: arg 2 must be a dictionary or None");
- return -1;
- }
- if (!PyMapping_Check(locals)) {
- PyErr_SetString(PyExc_TypeError,
- "exec: arg 3 must be a mapping or None");
- return -1;
- }
- if (PyDict_GetItemString(globals, "__builtins__") == NULL)
- PyDict_SetItemString(globals, "__builtins__", f->f_builtins);
- if (PyCode_Check(prog)) {
- if (PyCode_GetNumFree((PyCodeObject *)prog) > 0) {
- PyErr_SetString(PyExc_TypeError,
- "code object passed to exec may not contain free variables");
- return -1;
- }
- v = PyEval_EvalCode((PyCodeObject *) prog, globals, locals);
- }
- else if (PyFile_Check(prog)) {
- FILE *fp = PyFile_AsFile(prog);
- char *name = PyString_AsString(PyFile_Name(prog));
- PyCompilerFlags cf;
- cf.cf_flags = 0;
- if (PyEval_MergeCompilerFlags(&cf))
- v = PyRun_FileFlags(fp, name, Py_file_input, globals,
- locals, &cf);
- else
- v = PyRun_File(fp, name, Py_file_input, globals,
- locals);
- }
- else {
- PyObject *tmp = NULL;
- char *str;
- PyCompilerFlags cf;
- cf.cf_flags = 0;
-#ifdef Py_USING_UNICODE
- if (PyUnicode_Check(prog)) {
- tmp = PyUnicode_AsUTF8String(prog);
- if (tmp == NULL)
- return -1;
- prog = tmp;
- cf.cf_flags |= PyCF_SOURCE_IS_UTF8;
- }
-#endif
- if (PyString_AsStringAndSize(prog, &str, NULL))
- return -1;
- if (PyEval_MergeCompilerFlags(&cf))
- v = PyRun_StringFlags(str, Py_file_input, globals,
- locals, &cf);
- else
- v = PyRun_String(str, Py_file_input, globals, locals);
- Py_XDECREF(tmp);
- }
- if (plain)
- PyFrame_LocalsToFast(f, 0);
- if (v == NULL)
- return -1;
- Py_DECREF(v);
- return 0;
-}
-
static void
format_exc_check_arg(PyObject *exc, char *format_str, PyObject *obj)
{
diff --git a/Python/compile.c b/Python/compile.c
index 945a281..ac82b84 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -814,8 +814,6 @@ opcode_stack_effect(int opcode, int oparg)
return -1;
case IMPORT_STAR:
return -1;
- case EXEC_STMT:
- return -3;
case YIELD_VALUE:
return 0;
@@ -2112,21 +2110,6 @@ compiler_visit_stmt(struct compiler *c, stmt_ty s)
return compiler_import(c, s);
case ImportFrom_kind:
return compiler_from_import(c, s);
- case Exec_kind:
- VISIT(c, expr, s->v.Exec.body);
- if (s->v.Exec.globals) {
- VISIT(c, expr, s->v.Exec.globals);
- if (s->v.Exec.locals) {
- VISIT(c, expr, s->v.Exec.locals);
- } else {
- ADDOP(c, DUP_TOP);
- }
- } else {
- ADDOP_O(c, LOAD_CONST, Py_None, consts);
- ADDOP(c, DUP_TOP);
- }
- ADDOP(c, EXEC_STMT);
- break;
case Global_kind:
break;
case Expr_kind:
diff --git a/Python/graminit.c b/Python/graminit.c
index aeaa429..1d49a8c 100644
--- a/Python/graminit.c
+++ b/Python/graminit.c
@@ -253,7 +253,7 @@ static state states_11[4] = {
{2, arcs_11_2},
{1, arcs_11_3},
};
-static arc arcs_12_0[9] = {
+static arc arcs_12_0[8] = {
{33, 1},
{34, 1},
{35, 1},
@@ -262,29 +262,28 @@ static arc arcs_12_0[9] = {
{38, 1},
{39, 1},
{40, 1},
- {41, 1},
};
static arc arcs_12_1[1] = {
{0, 1},
};
static state states_12[2] = {
- {9, arcs_12_0},
+ {8, arcs_12_0},
{1, arcs_12_1},
};
static arc arcs_13_0[1] = {
{9, 1},
};
static arc arcs_13_1[3] = {
- {42, 2},
+ {41, 2},
{25, 3},
{0, 1},
};
static arc arcs_13_2[2] = {
- {43, 4},
+ {42, 4},
{9, 4},
};
static arc arcs_13_3[2] = {
- {43, 5},
+ {42, 5},
{9, 5},
};
static arc arcs_13_4[1] = {
@@ -303,6 +302,7 @@ static state states_13[6] = {
{2, arcs_13_5},
};
static arc arcs_14_0[12] = {
+ {43, 1},
{44, 1},
{45, 1},
{46, 1},
@@ -314,7 +314,6 @@ static arc arcs_14_0[12] = {
{52, 1},
{53, 1},
{54, 1},
- {55, 1},
};
static arc arcs_14_1[1] = {
{0, 1},
@@ -324,11 +323,11 @@ static state states_14[2] = {
{1, arcs_14_1},
};
static arc arcs_15_0[1] = {
- {56, 1},
+ {55, 1},
};
static arc arcs_15_1[3] = {
{26, 2},
- {57, 3},
+ {56, 3},
{0, 1},
};
static arc arcs_15_2[2] = {
@@ -369,10 +368,10 @@ static state states_15[9] = {
{2, arcs_15_8},
};
static arc arcs_16_0[1] = {
- {58, 1},
+ {57, 1},
};
static arc arcs_16_1[1] = {
- {59, 2},
+ {58, 2},
};
static arc arcs_16_2[1] = {
{0, 2},
@@ -383,7 +382,7 @@ static state states_16[3] = {
{1, arcs_16_2},
};
static arc arcs_17_0[1] = {
- {60, 1},
+ {59, 1},
};
static arc arcs_17_1[1] = {
{0, 1},
@@ -393,11 +392,11 @@ static state states_17[2] = {
{1, arcs_17_1},
};
static arc arcs_18_0[5] = {
+ {60, 1},
{61, 1},
{62, 1},
{63, 1},
{64, 1},
- {65, 1},
};
static arc arcs_18_1[1] = {
{0, 1},
@@ -407,7 +406,7 @@ static state states_18[2] = {
{1, arcs_18_1},
};
static arc arcs_19_0[1] = {
- {66, 1},
+ {65, 1},
};
static arc arcs_19_1[1] = {
{0, 1},
@@ -417,7 +416,7 @@ static state states_19[2] = {
{1, arcs_19_1},
};
static arc arcs_20_0[1] = {
- {67, 1},
+ {66, 1},
};
static arc arcs_20_1[1] = {
{0, 1},
@@ -427,7 +426,7 @@ static state states_20[2] = {
{1, arcs_20_1},
};
static arc arcs_21_0[1] = {
- {68, 1},
+ {67, 1},
};
static arc arcs_21_1[2] = {
{9, 2},
@@ -442,7 +441,7 @@ static state states_21[3] = {
{1, arcs_21_2},
};
static arc arcs_22_0[1] = {
- {43, 1},
+ {42, 1},
};
static arc arcs_22_1[1] = {
{0, 1},
@@ -452,7 +451,7 @@ static state states_22[2] = {
{1, arcs_22_1},
};
static arc arcs_23_0[1] = {
- {69, 1},
+ {68, 1},
};
static arc arcs_23_1[2] = {
{26, 2},
@@ -485,8 +484,8 @@ static state states_23[7] = {
{1, arcs_23_6},
};
static arc arcs_24_0[2] = {
+ {69, 1},
{70, 1},
- {71, 1},
};
static arc arcs_24_1[1] = {
{0, 1},
@@ -496,10 +495,10 @@ static state states_24[2] = {
{1, arcs_24_1},
};
static arc arcs_25_0[1] = {
- {72, 1},
+ {71, 1},
};
static arc arcs_25_1[1] = {
- {73, 2},
+ {72, 2},
};
static arc arcs_25_2[1] = {
{0, 2},
@@ -510,30 +509,30 @@ static state states_25[3] = {
{1, arcs_25_2},
};
static arc arcs_26_0[1] = {
- {74, 1},
+ {73, 1},
};
static arc arcs_26_1[2] = {
- {75, 2},
+ {74, 2},
{12, 3},
};
static arc arcs_26_2[3] = {
- {75, 2},
+ {74, 2},
{12, 3},
- {72, 4},
+ {71, 4},
};
static arc arcs_26_3[1] = {
- {72, 4},
+ {71, 4},
};
static arc arcs_26_4[3] = {
{28, 5},
{13, 6},
- {76, 5},
+ {75, 5},
};
static arc arcs_26_5[1] = {
{0, 5},
};
static arc arcs_26_6[1] = {
- {76, 7},
+ {75, 7},
};
static arc arcs_26_7[1] = {
{15, 5},
@@ -552,7 +551,7 @@ static arc arcs_27_0[1] = {
{19, 1},
};
static arc arcs_27_1[2] = {
- {78, 2},
+ {77, 2},
{0, 1},
};
static arc arcs_27_2[1] = {
@@ -571,7 +570,7 @@ static arc arcs_28_0[1] = {
{12, 1},
};
static arc arcs_28_1[2] = {
- {78, 2},
+ {77, 2},
{0, 1},
};
static arc arcs_28_2[1] = {
@@ -587,14 +586,14 @@ static state states_28[4] = {
{1, arcs_28_3},
};
static arc arcs_29_0[1] = {
- {77, 1},
+ {76, 1},
};
static arc arcs_29_1[2] = {
{27, 2},
{0, 1},
};
static arc arcs_29_2[2] = {
- {77, 1},
+ {76, 1},
{0, 2},
};
static state states_29[3] = {
@@ -603,7 +602,7 @@ static state states_29[3] = {
{2, arcs_29_2},
};
static arc arcs_30_0[1] = {
- {79, 1},
+ {78, 1},
};
static arc arcs_30_1[2] = {
{27, 0},
@@ -617,7 +616,7 @@ static arc arcs_31_0[1] = {
{19, 1},
};
static arc arcs_31_1[2] = {
- {75, 0},
+ {74, 0},
{0, 1},
};
static state states_31[2] = {
@@ -625,7 +624,7 @@ static state states_31[2] = {
{2, arcs_31_1},
};
static arc arcs_32_0[1] = {
- {80, 1},
+ {79, 1},
};
static arc arcs_32_1[1] = {
{19, 2},
@@ -640,78 +639,82 @@ static state states_32[3] = {
{2, arcs_32_2},
};
static arc arcs_33_0[1] = {
- {81, 1},
+ {80, 1},
};
static arc arcs_33_1[1] = {
- {82, 2},
+ {26, 2},
};
static arc arcs_33_2[2] = {
- {83, 3},
+ {27, 3},
{0, 2},
};
static arc arcs_33_3[1] = {
{26, 4},
};
-static arc arcs_33_4[2] = {
- {27, 5},
+static arc arcs_33_4[1] = {
{0, 4},
};
-static arc arcs_33_5[1] = {
- {26, 6},
-};
-static arc arcs_33_6[1] = {
- {0, 6},
-};
-static state states_33[7] = {
+static state states_33[5] = {
{1, arcs_33_0},
{1, arcs_33_1},
{2, arcs_33_2},
{1, arcs_33_3},
- {2, arcs_33_4},
- {1, arcs_33_5},
- {1, arcs_33_6},
+ {1, arcs_33_4},
};
-static arc arcs_34_0[1] = {
+static arc arcs_34_0[7] = {
+ {81, 1},
+ {82, 1},
+ {83, 1},
{84, 1},
+ {85, 1},
+ {17, 1},
+ {86, 1},
};
static arc arcs_34_1[1] = {
+ {0, 1},
+};
+static state states_34[2] = {
+ {7, arcs_34_0},
+ {1, arcs_34_1},
+};
+static arc arcs_35_0[1] = {
+ {87, 1},
+};
+static arc arcs_35_1[1] = {
{26, 2},
};
-static arc arcs_34_2[2] = {
- {27, 3},
- {0, 2},
+static arc arcs_35_2[1] = {
+ {21, 3},
};
-static arc arcs_34_3[1] = {
- {26, 4},
+static arc arcs_35_3[1] = {
+ {22, 4},
};
-static arc arcs_34_4[1] = {
+static arc arcs_35_4[3] = {
+ {88, 1},
+ {89, 5},
{0, 4},
};
-static state states_34[5] = {
- {1, arcs_34_0},
- {1, arcs_34_1},
- {2, arcs_34_2},
- {1, arcs_34_3},
- {1, arcs_34_4},
+static arc arcs_35_5[1] = {
+ {21, 6},
};
-static arc arcs_35_0[7] = {
- {85, 1},
- {86, 1},
- {87, 1},
- {88, 1},
- {89, 1},
- {17, 1},
- {90, 1},
+static arc arcs_35_6[1] = {
+ {22, 7},
};
-static arc arcs_35_1[1] = {
- {0, 1},
+static arc arcs_35_7[1] = {
+ {0, 7},
};
-static state states_35[2] = {
- {7, arcs_35_0},
+static state states_35[8] = {
+ {1, arcs_35_0},
{1, arcs_35_1},
+ {1, arcs_35_2},
+ {1, arcs_35_3},
+ {3, arcs_35_4},
+ {1, arcs_35_5},
+ {1, arcs_35_6},
+ {1, arcs_35_7},
};
static arc arcs_36_0[1] = {
- {91, 1},
+ {90, 1},
};
static arc arcs_36_1[1] = {
{26, 2},
@@ -722,9 +725,8 @@ static arc arcs_36_2[1] = {
static arc arcs_36_3[1] = {
{22, 4},
};
-static arc arcs_36_4[3] = {
- {92, 1},
- {93, 5},
+static arc arcs_36_4[2] = {
+ {89, 5},
{0, 4},
};
static arc arcs_36_5[1] = {
@@ -741,323 +743,299 @@ static state states_36[8] = {
{1, arcs_36_1},
{1, arcs_36_2},
{1, arcs_36_3},
- {3, arcs_36_4},
+ {2, arcs_36_4},
{1, arcs_36_5},
{1, arcs_36_6},
{1, arcs_36_7},
};
static arc arcs_37_0[1] = {
- {94, 1},
+ {91, 1},
};
static arc arcs_37_1[1] = {
- {26, 2},
+ {58, 2},
};
static arc arcs_37_2[1] = {
- {21, 3},
+ {92, 3},
};
static arc arcs_37_3[1] = {
- {22, 4},
+ {9, 4},
};
-static arc arcs_37_4[2] = {
- {93, 5},
- {0, 4},
+static arc arcs_37_4[1] = {
+ {21, 5},
};
static arc arcs_37_5[1] = {
- {21, 6},
+ {22, 6},
};
-static arc arcs_37_6[1] = {
- {22, 7},
+static arc arcs_37_6[2] = {
+ {89, 7},
+ {0, 6},
};
static arc arcs_37_7[1] = {
- {0, 7},
+ {21, 8},
};
-static state states_37[8] = {
+static arc arcs_37_8[1] = {
+ {22, 9},
+};
+static arc arcs_37_9[1] = {
+ {0, 9},
+};
+static state states_37[10] = {
{1, arcs_37_0},
{1, arcs_37_1},
{1, arcs_37_2},
{1, arcs_37_3},
- {2, arcs_37_4},
+ {1, arcs_37_4},
{1, arcs_37_5},
- {1, arcs_37_6},
+ {2, arcs_37_6},
{1, arcs_37_7},
+ {1, arcs_37_8},
+ {1, arcs_37_9},
};
static arc arcs_38_0[1] = {
- {95, 1},
+ {93, 1},
};
static arc arcs_38_1[1] = {
- {59, 2},
+ {21, 2},
};
static arc arcs_38_2[1] = {
- {83, 3},
+ {22, 3},
};
-static arc arcs_38_3[1] = {
- {9, 4},
+static arc arcs_38_3[2] = {
+ {94, 4},
+ {95, 5},
};
static arc arcs_38_4[1] = {
- {21, 5},
+ {21, 6},
};
static arc arcs_38_5[1] = {
- {22, 6},
+ {21, 7},
};
-static arc arcs_38_6[2] = {
- {93, 7},
- {0, 6},
+static arc arcs_38_6[1] = {
+ {22, 8},
};
static arc arcs_38_7[1] = {
- {21, 8},
-};
-static arc arcs_38_8[1] = {
{22, 9},
};
+static arc arcs_38_8[4] = {
+ {94, 4},
+ {89, 10},
+ {95, 5},
+ {0, 8},
+};
static arc arcs_38_9[1] = {
{0, 9},
};
-static state states_38[10] = {
+static arc arcs_38_10[1] = {
+ {21, 11},
+};
+static arc arcs_38_11[1] = {
+ {22, 12},
+};
+static arc arcs_38_12[2] = {
+ {95, 5},
+ {0, 12},
+};
+static state states_38[13] = {
{1, arcs_38_0},
{1, arcs_38_1},
{1, arcs_38_2},
- {1, arcs_38_3},
+ {2, arcs_38_3},
{1, arcs_38_4},
{1, arcs_38_5},
- {2, arcs_38_6},
+ {1, arcs_38_6},
{1, arcs_38_7},
- {1, arcs_38_8},
+ {4, arcs_38_8},
{1, arcs_38_9},
+ {1, arcs_38_10},
+ {1, arcs_38_11},
+ {2, arcs_38_12},
};
static arc arcs_39_0[1] = {
{96, 1},
};
static arc arcs_39_1[1] = {
- {21, 2},
+ {26, 2},
};
-static arc arcs_39_2[1] = {
- {22, 3},
+static arc arcs_39_2[2] = {
+ {97, 3},
+ {21, 4},
};
-static arc arcs_39_3[2] = {
- {97, 4},
- {98, 5},
+static arc arcs_39_3[1] = {
+ {21, 4},
};
static arc arcs_39_4[1] = {
- {21, 6},
+ {22, 5},
};
static arc arcs_39_5[1] = {
- {21, 7},
-};
-static arc arcs_39_6[1] = {
- {22, 8},
-};
-static arc arcs_39_7[1] = {
- {22, 9},
-};
-static arc arcs_39_8[4] = {
- {97, 4},
- {93, 10},
- {98, 5},
- {0, 8},
-};
-static arc arcs_39_9[1] = {
- {0, 9},
-};
-static arc arcs_39_10[1] = {
- {21, 11},
-};
-static arc arcs_39_11[1] = {
- {22, 12},
-};
-static arc arcs_39_12[2] = {
- {98, 5},
- {0, 12},
+ {0, 5},
};
-static state states_39[13] = {
+static state states_39[6] = {
{1, arcs_39_0},
{1, arcs_39_1},
- {1, arcs_39_2},
- {2, arcs_39_3},
+ {2, arcs_39_2},
+ {1, arcs_39_3},
{1, arcs_39_4},
{1, arcs_39_5},
- {1, arcs_39_6},
- {1, arcs_39_7},
- {4, arcs_39_8},
- {1, arcs_39_9},
- {1, arcs_39_10},
- {1, arcs_39_11},
- {2, arcs_39_12},
};
static arc arcs_40_0[1] = {
- {99, 1},
+ {77, 1},
};
static arc arcs_40_1[1] = {
- {26, 2},
-};
-static arc arcs_40_2[2] = {
- {100, 3},
- {21, 4},
-};
-static arc arcs_40_3[1] = {
- {21, 4},
-};
-static arc arcs_40_4[1] = {
- {22, 5},
+ {98, 2},
};
-static arc arcs_40_5[1] = {
- {0, 5},
+static arc arcs_40_2[1] = {
+ {0, 2},
};
-static state states_40[6] = {
+static state states_40[3] = {
{1, arcs_40_0},
{1, arcs_40_1},
- {2, arcs_40_2},
- {1, arcs_40_3},
- {1, arcs_40_4},
- {1, arcs_40_5},
+ {1, arcs_40_2},
};
static arc arcs_41_0[1] = {
- {78, 1},
-};
-static arc arcs_41_1[1] = {
- {82, 2},
-};
-static arc arcs_41_2[1] = {
- {0, 2},
-};
-static state states_41[3] = {
- {1, arcs_41_0},
- {1, arcs_41_1},
- {1, arcs_41_2},
-};
-static arc arcs_42_0[1] = {
- {101, 1},
+ {99, 1},
};
-static arc arcs_42_1[2] = {
+static arc arcs_41_1[2] = {
{26, 2},
{0, 1},
};
-static arc arcs_42_2[2] = {
+static arc arcs_41_2[2] = {
{27, 3},
{0, 2},
};
-static arc arcs_42_3[1] = {
+static arc arcs_41_3[1] = {
{26, 4},
};
-static arc arcs_42_4[1] = {
+static arc arcs_41_4[1] = {
{0, 4},
};
-static state states_42[5] = {
- {1, arcs_42_0},
- {2, arcs_42_1},
- {2, arcs_42_2},
- {1, arcs_42_3},
- {1, arcs_42_4},
+static state states_41[5] = {
+ {1, arcs_41_0},
+ {2, arcs_41_1},
+ {2, arcs_41_2},
+ {1, arcs_41_3},
+ {1, arcs_41_4},
};
-static arc arcs_43_0[2] = {
+static arc arcs_42_0[2] = {
{3, 1},
{2, 2},
};
-static arc arcs_43_1[1] = {
+static arc arcs_42_1[1] = {
{0, 1},
};
-static arc arcs_43_2[1] = {
- {102, 3},
+static arc arcs_42_2[1] = {
+ {100, 3},
};
-static arc arcs_43_3[1] = {
+static arc arcs_42_3[1] = {
{6, 4},
};
-static arc arcs_43_4[2] = {
+static arc arcs_42_4[2] = {
{6, 4},
- {103, 1},
+ {101, 1},
};
-static state states_43[5] = {
- {2, arcs_43_0},
- {1, arcs_43_1},
- {1, arcs_43_2},
- {1, arcs_43_3},
- {2, arcs_43_4},
+static state states_42[5] = {
+ {2, arcs_42_0},
+ {1, arcs_42_1},
+ {1, arcs_42_2},
+ {1, arcs_42_3},
+ {2, arcs_42_4},
};
-static arc arcs_44_0[1] = {
- {105, 1},
+static arc arcs_43_0[1] = {
+ {103, 1},
};
-static arc arcs_44_1[2] = {
+static arc arcs_43_1[2] = {
{27, 2},
{0, 1},
};
-static arc arcs_44_2[1] = {
- {105, 3},
+static arc arcs_43_2[1] = {
+ {103, 3},
};
-static arc arcs_44_3[2] = {
+static arc arcs_43_3[2] = {
{27, 4},
{0, 3},
};
-static arc arcs_44_4[2] = {
- {105, 3},
+static arc arcs_43_4[2] = {
+ {103, 3},
{0, 4},
};
-static state states_44[5] = {
- {1, arcs_44_0},
- {2, arcs_44_1},
- {1, arcs_44_2},
- {2, arcs_44_3},
- {2, arcs_44_4},
+static state states_43[5] = {
+ {1, arcs_43_0},
+ {2, arcs_43_1},
+ {1, arcs_43_2},
+ {2, arcs_43_3},
+ {2, arcs_43_4},
};
-static arc arcs_45_0[2] = {
- {106, 1},
- {107, 1},
+static arc arcs_44_0[2] = {
+ {104, 1},
+ {105, 1},
};
-static arc arcs_45_1[1] = {
+static arc arcs_44_1[1] = {
{0, 1},
};
-static state states_45[2] = {
- {2, arcs_45_0},
- {1, arcs_45_1},
+static state states_44[2] = {
+ {2, arcs_44_0},
+ {1, arcs_44_1},
};
-static arc arcs_46_0[1] = {
- {108, 1},
+static arc arcs_45_0[1] = {
+ {106, 1},
};
-static arc arcs_46_1[2] = {
+static arc arcs_45_1[2] = {
{23, 2},
{21, 3},
};
-static arc arcs_46_2[1] = {
+static arc arcs_45_2[1] = {
{21, 3},
};
-static arc arcs_46_3[1] = {
- {105, 4},
+static arc arcs_45_3[1] = {
+ {103, 4},
};
-static arc arcs_46_4[1] = {
+static arc arcs_45_4[1] = {
{0, 4},
};
-static state states_46[5] = {
- {1, arcs_46_0},
- {2, arcs_46_1},
- {1, arcs_46_2},
- {1, arcs_46_3},
- {1, arcs_46_4},
+static state states_45[5] = {
+ {1, arcs_45_0},
+ {2, arcs_45_1},
+ {1, arcs_45_2},
+ {1, arcs_45_3},
+ {1, arcs_45_4},
};
-static arc arcs_47_0[2] = {
- {106, 1},
- {109, 2},
+static arc arcs_46_0[2] = {
+ {104, 1},
+ {107, 2},
};
-static arc arcs_47_1[2] = {
- {91, 3},
+static arc arcs_46_1[2] = {
+ {87, 3},
{0, 1},
};
-static arc arcs_47_2[1] = {
+static arc arcs_46_2[1] = {
{0, 2},
};
-static arc arcs_47_3[1] = {
- {106, 4},
+static arc arcs_46_3[1] = {
+ {104, 4},
};
-static arc arcs_47_4[1] = {
- {93, 5},
+static arc arcs_46_4[1] = {
+ {89, 5},
};
-static arc arcs_47_5[1] = {
+static arc arcs_46_5[1] = {
{26, 2},
};
-static state states_47[6] = {
- {2, arcs_47_0},
+static state states_46[6] = {
+ {2, arcs_46_0},
+ {2, arcs_46_1},
+ {1, arcs_46_2},
+ {1, arcs_46_3},
+ {1, arcs_46_4},
+ {1, arcs_46_5},
+};
+static arc arcs_47_0[1] = {
+ {108, 1},
+};
+static arc arcs_47_1[2] = {
+ {109, 0},
+ {0, 1},
+};
+static state states_47[2] = {
+ {1, arcs_47_0},
{2, arcs_47_1},
- {1, arcs_47_2},
- {1, arcs_47_3},
- {1, arcs_47_4},
- {1, arcs_47_5},
};
static arc arcs_48_0[1] = {
{110, 1},
@@ -1070,69 +1048,69 @@ static state states_48[2] = {
{1, arcs_48_0},
{2, arcs_48_1},
};
-static arc arcs_49_0[1] = {
+static arc arcs_49_0[2] = {
{112, 1},
+ {113, 2},
};
-static arc arcs_49_1[2] = {
- {113, 0},
- {0, 1},
-};
-static state states_49[2] = {
- {1, arcs_49_0},
- {2, arcs_49_1},
+static arc arcs_49_1[1] = {
+ {110, 2},
};
-static arc arcs_50_0[2] = {
- {114, 1},
- {115, 2},
-};
-static arc arcs_50_1[1] = {
- {112, 2},
-};
-static arc arcs_50_2[1] = {
+static arc arcs_49_2[1] = {
{0, 2},
};
-static state states_50[3] = {
- {2, arcs_50_0},
- {1, arcs_50_1},
- {1, arcs_50_2},
+static state states_49[3] = {
+ {2, arcs_49_0},
+ {1, arcs_49_1},
+ {1, arcs_49_2},
};
-static arc arcs_51_0[1] = {
- {82, 1},
+static arc arcs_50_0[1] = {
+ {98, 1},
};
-static arc arcs_51_1[2] = {
- {116, 0},
+static arc arcs_50_1[2] = {
+ {114, 0},
{0, 1},
};
-static state states_51[2] = {
- {1, arcs_51_0},
- {2, arcs_51_1},
+static state states_50[2] = {
+ {1, arcs_50_0},
+ {2, arcs_50_1},
};
-static arc arcs_52_0[9] = {
+static arc arcs_51_0[9] = {
+ {115, 1},
+ {116, 1},
{117, 1},
{118, 1},
{119, 1},
{120, 1},
- {121, 1},
- {122, 1},
- {83, 1},
- {114, 2},
- {123, 3},
+ {92, 1},
+ {112, 2},
+ {121, 3},
};
-static arc arcs_52_1[1] = {
+static arc arcs_51_1[1] = {
{0, 1},
};
-static arc arcs_52_2[1] = {
- {83, 1},
+static arc arcs_51_2[1] = {
+ {92, 1},
};
-static arc arcs_52_3[2] = {
- {114, 1},
+static arc arcs_51_3[2] = {
+ {112, 1},
{0, 3},
};
-static state states_52[4] = {
- {9, arcs_52_0},
- {1, arcs_52_1},
- {1, arcs_52_2},
- {2, arcs_52_3},
+static state states_51[4] = {
+ {9, arcs_51_0},
+ {1, arcs_51_1},
+ {1, arcs_51_2},
+ {2, arcs_51_3},
+};
+static arc arcs_52_0[1] = {
+ {122, 1},
+};
+static arc arcs_52_1[2] = {
+ {123, 0},
+ {0, 1},
+};
+static state states_52[2] = {
+ {1, arcs_52_0},
+ {2, arcs_52_1},
};
static arc arcs_53_0[1] = {
{124, 1},
@@ -1159,20 +1137,21 @@ static state states_54[2] = {
static arc arcs_55_0[1] = {
{128, 1},
};
-static arc arcs_55_1[2] = {
+static arc arcs_55_1[3] = {
{129, 0},
+ {56, 0},
{0, 1},
};
static state states_55[2] = {
{1, arcs_55_0},
- {2, arcs_55_1},
+ {3, arcs_55_1},
};
static arc arcs_56_0[1] = {
{130, 1},
};
static arc arcs_56_1[3] = {
{131, 0},
- {57, 0},
+ {132, 0},
{0, 1},
};
static state states_56[2] = {
@@ -1180,121 +1159,135 @@ static state states_56[2] = {
{3, arcs_56_1},
};
static arc arcs_57_0[1] = {
- {132, 1},
+ {133, 1},
};
-static arc arcs_57_1[3] = {
- {133, 0},
+static arc arcs_57_1[5] = {
+ {28, 0},
{134, 0},
+ {135, 0},
+ {136, 0},
{0, 1},
};
static state states_57[2] = {
{1, arcs_57_0},
- {3, arcs_57_1},
-};
-static arc arcs_58_0[1] = {
- {135, 1},
-};
-static arc arcs_58_1[5] = {
- {28, 0},
- {136, 0},
- {137, 0},
- {138, 0},
- {0, 1},
-};
-static state states_58[2] = {
- {1, arcs_58_0},
- {5, arcs_58_1},
+ {5, arcs_57_1},
};
-static arc arcs_59_0[4] = {
- {133, 1},
- {134, 1},
- {139, 1},
- {140, 2},
+static arc arcs_58_0[4] = {
+ {131, 1},
+ {132, 1},
+ {137, 1},
+ {138, 2},
};
-static arc arcs_59_1[1] = {
- {135, 2},
+static arc arcs_58_1[1] = {
+ {133, 2},
};
-static arc arcs_59_2[1] = {
+static arc arcs_58_2[1] = {
{0, 2},
};
-static state states_59[3] = {
- {4, arcs_59_0},
- {1, arcs_59_1},
- {1, arcs_59_2},
+static state states_58[3] = {
+ {4, arcs_58_0},
+ {1, arcs_58_1},
+ {1, arcs_58_2},
};
-static arc arcs_60_0[1] = {
- {141, 1},
+static arc arcs_59_0[1] = {
+ {139, 1},
};
-static arc arcs_60_1[3] = {
- {142, 1},
+static arc arcs_59_1[3] = {
+ {140, 1},
{29, 2},
{0, 1},
};
-static arc arcs_60_2[1] = {
- {135, 3},
+static arc arcs_59_2[1] = {
+ {133, 3},
};
-static arc arcs_60_3[1] = {
+static arc arcs_59_3[1] = {
{0, 3},
};
-static state states_60[4] = {
- {1, arcs_60_0},
- {3, arcs_60_1},
- {1, arcs_60_2},
- {1, arcs_60_3},
+static state states_59[4] = {
+ {1, arcs_59_0},
+ {3, arcs_59_1},
+ {1, arcs_59_2},
+ {1, arcs_59_3},
};
-static arc arcs_61_0[6] = {
+static arc arcs_60_0[6] = {
{13, 1},
- {144, 2},
- {147, 3},
+ {142, 2},
+ {145, 3},
{19, 4},
- {150, 4},
- {151, 5},
+ {148, 4},
+ {149, 5},
};
-static arc arcs_61_1[3] = {
- {43, 6},
- {143, 6},
+static arc arcs_60_1[3] = {
+ {42, 6},
+ {141, 6},
{15, 4},
};
-static arc arcs_61_2[2] = {
- {145, 7},
- {146, 4},
+static arc arcs_60_2[2] = {
+ {143, 7},
+ {144, 4},
};
-static arc arcs_61_3[2] = {
- {148, 8},
- {149, 4},
+static arc arcs_60_3[2] = {
+ {146, 8},
+ {147, 4},
};
-static arc arcs_61_4[1] = {
+static arc arcs_60_4[1] = {
{0, 4},
};
-static arc arcs_61_5[2] = {
- {151, 5},
+static arc arcs_60_5[2] = {
+ {149, 5},
{0, 5},
};
-static arc arcs_61_6[1] = {
+static arc arcs_60_6[1] = {
{15, 4},
};
-static arc arcs_61_7[1] = {
- {146, 4},
+static arc arcs_60_7[1] = {
+ {144, 4},
+};
+static arc arcs_60_8[1] = {
+ {147, 4},
};
-static arc arcs_61_8[1] = {
- {149, 4},
+static state states_60[9] = {
+ {6, arcs_60_0},
+ {3, arcs_60_1},
+ {2, arcs_60_2},
+ {2, arcs_60_3},
+ {1, arcs_60_4},
+ {2, arcs_60_5},
+ {1, arcs_60_6},
+ {1, arcs_60_7},
+ {1, arcs_60_8},
+};
+static arc arcs_61_0[1] = {
+ {26, 1},
+};
+static arc arcs_61_1[3] = {
+ {150, 2},
+ {27, 3},
+ {0, 1},
+};
+static arc arcs_61_2[1] = {
+ {0, 2},
};
-static state states_61[9] = {
- {6, arcs_61_0},
+static arc arcs_61_3[2] = {
+ {26, 4},
+ {0, 3},
+};
+static arc arcs_61_4[2] = {
+ {27, 3},
+ {0, 4},
+};
+static state states_61[5] = {
+ {1, arcs_61_0},
{3, arcs_61_1},
- {2, arcs_61_2},
+ {1, arcs_61_2},
{2, arcs_61_3},
- {1, arcs_61_4},
- {2, arcs_61_5},
- {1, arcs_61_6},
- {1, arcs_61_7},
- {1, arcs_61_8},
+ {2, arcs_61_4},
};
static arc arcs_62_0[1] = {
{26, 1},
};
static arc arcs_62_1[3] = {
- {152, 2},
+ {151, 2},
{27, 3},
{0, 1},
};
@@ -1317,163 +1310,153 @@ static state states_62[5] = {
{2, arcs_62_4},
};
static arc arcs_63_0[1] = {
- {26, 1},
+ {106, 1},
};
-static arc arcs_63_1[3] = {
- {153, 2},
- {27, 3},
- {0, 1},
+static arc arcs_63_1[2] = {
+ {23, 2},
+ {21, 3},
};
static arc arcs_63_2[1] = {
- {0, 2},
+ {21, 3},
};
-static arc arcs_63_3[2] = {
+static arc arcs_63_3[1] = {
{26, 4},
- {0, 3},
};
-static arc arcs_63_4[2] = {
- {27, 3},
+static arc arcs_63_4[1] = {
{0, 4},
};
static state states_63[5] = {
{1, arcs_63_0},
- {3, arcs_63_1},
+ {2, arcs_63_1},
{1, arcs_63_2},
- {2, arcs_63_3},
- {2, arcs_63_4},
+ {1, arcs_63_3},
+ {1, arcs_63_4},
};
-static arc arcs_64_0[1] = {
- {108, 1},
+static arc arcs_64_0[3] = {
+ {13, 1},
+ {142, 2},
+ {74, 3},
};
static arc arcs_64_1[2] = {
- {23, 2},
- {21, 3},
+ {14, 4},
+ {15, 5},
};
static arc arcs_64_2[1] = {
- {21, 3},
+ {152, 6},
};
static arc arcs_64_3[1] = {
- {26, 4},
+ {19, 5},
};
static arc arcs_64_4[1] = {
- {0, 4},
+ {15, 5},
};
-static state states_64[5] = {
- {1, arcs_64_0},
+static arc arcs_64_5[1] = {
+ {0, 5},
+};
+static arc arcs_64_6[1] = {
+ {144, 5},
+};
+static state states_64[7] = {
+ {3, arcs_64_0},
{2, arcs_64_1},
{1, arcs_64_2},
{1, arcs_64_3},
{1, arcs_64_4},
+ {1, arcs_64_5},
+ {1, arcs_64_6},
};
-static arc arcs_65_0[3] = {
- {13, 1},
- {144, 2},
- {75, 3},
+static arc arcs_65_0[1] = {
+ {153, 1},
};
static arc arcs_65_1[2] = {
- {14, 4},
- {15, 5},
-};
-static arc arcs_65_2[1] = {
- {154, 6},
-};
-static arc arcs_65_3[1] = {
- {19, 5},
-};
-static arc arcs_65_4[1] = {
- {15, 5},
-};
-static arc arcs_65_5[1] = {
- {0, 5},
-};
-static arc arcs_65_6[1] = {
- {146, 5},
-};
-static state states_65[7] = {
- {3, arcs_65_0},
- {2, arcs_65_1},
- {1, arcs_65_2},
- {1, arcs_65_3},
- {1, arcs_65_4},
- {1, arcs_65_5},
- {1, arcs_65_6},
-};
-static arc arcs_66_0[1] = {
- {155, 1},
-};
-static arc arcs_66_1[2] = {
{27, 2},
{0, 1},
};
-static arc arcs_66_2[2] = {
- {155, 1},
+static arc arcs_65_2[2] = {
+ {153, 1},
{0, 2},
};
-static state states_66[3] = {
- {1, arcs_66_0},
- {2, arcs_66_1},
- {2, arcs_66_2},
+static state states_65[3] = {
+ {1, arcs_65_0},
+ {2, arcs_65_1},
+ {2, arcs_65_2},
};
-static arc arcs_67_0[3] = {
- {75, 1},
+static arc arcs_66_0[3] = {
+ {74, 1},
{26, 2},
{21, 3},
};
-static arc arcs_67_1[1] = {
- {75, 4},
+static arc arcs_66_1[1] = {
+ {74, 4},
};
-static arc arcs_67_2[2] = {
+static arc arcs_66_2[2] = {
{21, 3},
{0, 2},
};
-static arc arcs_67_3[3] = {
+static arc arcs_66_3[3] = {
{26, 5},
- {156, 6},
+ {154, 6},
{0, 3},
};
-static arc arcs_67_4[1] = {
- {75, 6},
+static arc arcs_66_4[1] = {
+ {74, 6},
};
-static arc arcs_67_5[2] = {
- {156, 6},
+static arc arcs_66_5[2] = {
+ {154, 6},
{0, 5},
};
-static arc arcs_67_6[1] = {
+static arc arcs_66_6[1] = {
{0, 6},
};
-static state states_67[7] = {
- {3, arcs_67_0},
- {1, arcs_67_1},
- {2, arcs_67_2},
- {3, arcs_67_3},
- {1, arcs_67_4},
- {2, arcs_67_5},
- {1, arcs_67_6},
+static state states_66[7] = {
+ {3, arcs_66_0},
+ {1, arcs_66_1},
+ {2, arcs_66_2},
+ {3, arcs_66_3},
+ {1, arcs_66_4},
+ {2, arcs_66_5},
+ {1, arcs_66_6},
};
-static arc arcs_68_0[1] = {
+static arc arcs_67_0[1] = {
{21, 1},
};
-static arc arcs_68_1[2] = {
+static arc arcs_67_1[2] = {
{26, 2},
{0, 1},
};
-static arc arcs_68_2[1] = {
+static arc arcs_67_2[1] = {
+ {0, 2},
+};
+static state states_67[3] = {
+ {1, arcs_67_0},
+ {2, arcs_67_1},
+ {1, arcs_67_2},
+};
+static arc arcs_68_0[1] = {
+ {98, 1},
+};
+static arc arcs_68_1[2] = {
+ {27, 2},
+ {0, 1},
+};
+static arc arcs_68_2[2] = {
+ {98, 1},
{0, 2},
};
static state states_68[3] = {
{1, arcs_68_0},
{2, arcs_68_1},
- {1, arcs_68_2},
+ {2, arcs_68_2},
};
static arc arcs_69_0[1] = {
- {82, 1},
+ {26, 1},
};
static arc arcs_69_1[2] = {
{27, 2},
{0, 1},
};
static arc arcs_69_2[2] = {
- {82, 1},
+ {26, 1},
{0, 2},
};
static state states_69[3] = {
@@ -1484,313 +1467,297 @@ static state states_69[3] = {
static arc arcs_70_0[1] = {
{26, 1},
};
-static arc arcs_70_1[2] = {
- {27, 2},
- {0, 1},
-};
-static arc arcs_70_2[2] = {
- {26, 1},
- {0, 2},
-};
-static state states_70[3] = {
- {1, arcs_70_0},
- {2, arcs_70_1},
- {2, arcs_70_2},
-};
-static arc arcs_71_0[1] = {
- {26, 1},
-};
-static arc arcs_71_1[3] = {
+static arc arcs_70_1[3] = {
{21, 2},
{27, 3},
{0, 1},
};
-static arc arcs_71_2[1] = {
+static arc arcs_70_2[1] = {
{26, 4},
};
-static arc arcs_71_3[2] = {
+static arc arcs_70_3[2] = {
{26, 5},
{0, 3},
};
-static arc arcs_71_4[2] = {
+static arc arcs_70_4[2] = {
{27, 6},
{0, 4},
};
-static arc arcs_71_5[2] = {
+static arc arcs_70_5[2] = {
{27, 3},
{0, 5},
};
-static arc arcs_71_6[2] = {
+static arc arcs_70_6[2] = {
{26, 7},
{0, 6},
};
-static arc arcs_71_7[1] = {
+static arc arcs_70_7[1] = {
{21, 2},
};
-static state states_71[8] = {
- {1, arcs_71_0},
- {3, arcs_71_1},
- {1, arcs_71_2},
- {2, arcs_71_3},
- {2, arcs_71_4},
- {2, arcs_71_5},
- {2, arcs_71_6},
- {1, arcs_71_7},
+static state states_70[8] = {
+ {1, arcs_70_0},
+ {3, arcs_70_1},
+ {1, arcs_70_2},
+ {2, arcs_70_3},
+ {2, arcs_70_4},
+ {2, arcs_70_5},
+ {2, arcs_70_6},
+ {1, arcs_70_7},
};
-static arc arcs_72_0[1] = {
- {157, 1},
+static arc arcs_71_0[1] = {
+ {155, 1},
};
-static arc arcs_72_1[1] = {
+static arc arcs_71_1[1] = {
{19, 2},
};
-static arc arcs_72_2[2] = {
+static arc arcs_71_2[2] = {
{13, 3},
{21, 4},
};
-static arc arcs_72_3[2] = {
+static arc arcs_71_3[2] = {
{9, 5},
{15, 6},
};
-static arc arcs_72_4[1] = {
+static arc arcs_71_4[1] = {
{22, 7},
};
-static arc arcs_72_5[1] = {
+static arc arcs_71_5[1] = {
{15, 6},
};
-static arc arcs_72_6[1] = {
+static arc arcs_71_6[1] = {
{21, 4},
};
-static arc arcs_72_7[1] = {
+static arc arcs_71_7[1] = {
{0, 7},
};
-static state states_72[8] = {
- {1, arcs_72_0},
- {1, arcs_72_1},
- {2, arcs_72_2},
- {2, arcs_72_3},
- {1, arcs_72_4},
- {1, arcs_72_5},
- {1, arcs_72_6},
- {1, arcs_72_7},
+static state states_71[8] = {
+ {1, arcs_71_0},
+ {1, arcs_71_1},
+ {2, arcs_71_2},
+ {2, arcs_71_3},
+ {1, arcs_71_4},
+ {1, arcs_71_5},
+ {1, arcs_71_6},
+ {1, arcs_71_7},
};
-static arc arcs_73_0[3] = {
- {158, 1},
+static arc arcs_72_0[3] = {
+ {156, 1},
{28, 2},
{29, 3},
};
-static arc arcs_73_1[2] = {
+static arc arcs_72_1[2] = {
{27, 4},
{0, 1},
};
-static arc arcs_73_2[1] = {
+static arc arcs_72_2[1] = {
{26, 5},
};
-static arc arcs_73_3[1] = {
+static arc arcs_72_3[1] = {
{26, 6},
};
-static arc arcs_73_4[4] = {
- {158, 1},
+static arc arcs_72_4[4] = {
+ {156, 1},
{28, 2},
{29, 3},
{0, 4},
};
-static arc arcs_73_5[2] = {
+static arc arcs_72_5[2] = {
{27, 7},
{0, 5},
};
-static arc arcs_73_6[1] = {
+static arc arcs_72_6[1] = {
{0, 6},
};
-static arc arcs_73_7[1] = {
+static arc arcs_72_7[1] = {
{29, 3},
};
-static state states_73[8] = {
- {3, arcs_73_0},
- {2, arcs_73_1},
- {1, arcs_73_2},
- {1, arcs_73_3},
- {4, arcs_73_4},
- {2, arcs_73_5},
- {1, arcs_73_6},
- {1, arcs_73_7},
+static state states_72[8] = {
+ {3, arcs_72_0},
+ {2, arcs_72_1},
+ {1, arcs_72_2},
+ {1, arcs_72_3},
+ {4, arcs_72_4},
+ {2, arcs_72_5},
+ {1, arcs_72_6},
+ {1, arcs_72_7},
};
-static arc arcs_74_0[1] = {
+static arc arcs_73_0[1] = {
{26, 1},
};
-static arc arcs_74_1[3] = {
- {153, 2},
+static arc arcs_73_1[3] = {
+ {151, 2},
{25, 3},
{0, 1},
};
-static arc arcs_74_2[1] = {
+static arc arcs_73_2[1] = {
{0, 2},
};
-static arc arcs_74_3[1] = {
+static arc arcs_73_3[1] = {
{26, 2},
};
-static state states_74[4] = {
- {1, arcs_74_0},
- {3, arcs_74_1},
- {1, arcs_74_2},
- {1, arcs_74_3},
+static state states_73[4] = {
+ {1, arcs_73_0},
+ {3, arcs_73_1},
+ {1, arcs_73_2},
+ {1, arcs_73_3},
};
-static arc arcs_75_0[2] = {
- {152, 1},
- {160, 1},
+static arc arcs_74_0[2] = {
+ {150, 1},
+ {158, 1},
};
-static arc arcs_75_1[1] = {
+static arc arcs_74_1[1] = {
{0, 1},
};
-static state states_75[2] = {
- {2, arcs_75_0},
- {1, arcs_75_1},
+static state states_74[2] = {
+ {2, arcs_74_0},
+ {1, arcs_74_1},
};
-static arc arcs_76_0[1] = {
- {95, 1},
+static arc arcs_75_0[1] = {
+ {91, 1},
};
-static arc arcs_76_1[1] = {
- {59, 2},
+static arc arcs_75_1[1] = {
+ {58, 2},
};
-static arc arcs_76_2[1] = {
- {83, 3},
+static arc arcs_75_2[1] = {
+ {92, 3},
};
-static arc arcs_76_3[1] = {
- {104, 4},
+static arc arcs_75_3[1] = {
+ {102, 4},
};
-static arc arcs_76_4[2] = {
- {159, 5},
+static arc arcs_75_4[2] = {
+ {157, 5},
{0, 4},
};
-static arc arcs_76_5[1] = {
+static arc arcs_75_5[1] = {
{0, 5},
};
-static state states_76[6] = {
- {1, arcs_76_0},
- {1, arcs_76_1},
- {1, arcs_76_2},
- {1, arcs_76_3},
- {2, arcs_76_4},
- {1, arcs_76_5},
+static state states_75[6] = {
+ {1, arcs_75_0},
+ {1, arcs_75_1},
+ {1, arcs_75_2},
+ {1, arcs_75_3},
+ {2, arcs_75_4},
+ {1, arcs_75_5},
};
-static arc arcs_77_0[1] = {
- {91, 1},
+static arc arcs_76_0[1] = {
+ {87, 1},
};
-static arc arcs_77_1[1] = {
- {105, 2},
+static arc arcs_76_1[1] = {
+ {103, 2},
};
-static arc arcs_77_2[2] = {
- {159, 3},
+static arc arcs_76_2[2] = {
+ {157, 3},
{0, 2},
};
-static arc arcs_77_3[1] = {
+static arc arcs_76_3[1] = {
{0, 3},
};
-static state states_77[4] = {
- {1, arcs_77_0},
- {1, arcs_77_1},
- {2, arcs_77_2},
- {1, arcs_77_3},
+static state states_76[4] = {
+ {1, arcs_76_0},
+ {1, arcs_76_1},
+ {2, arcs_76_2},
+ {1, arcs_76_3},
};
-static arc arcs_78_0[2] = {
- {153, 1},
- {162, 1},
+static arc arcs_77_0[2] = {
+ {151, 1},
+ {160, 1},
};
-static arc arcs_78_1[1] = {
+static arc arcs_77_1[1] = {
{0, 1},
};
-static state states_78[2] = {
- {2, arcs_78_0},
- {1, arcs_78_1},
+static state states_77[2] = {
+ {2, arcs_77_0},
+ {1, arcs_77_1},
};
-static arc arcs_79_0[1] = {
- {95, 1},
+static arc arcs_78_0[1] = {
+ {91, 1},
};
-static arc arcs_79_1[1] = {
- {59, 2},
+static arc arcs_78_1[1] = {
+ {58, 2},
};
-static arc arcs_79_2[1] = {
- {83, 3},
+static arc arcs_78_2[1] = {
+ {92, 3},
};
-static arc arcs_79_3[1] = {
- {106, 4},
+static arc arcs_78_3[1] = {
+ {104, 4},
};
-static arc arcs_79_4[2] = {
- {161, 5},
+static arc arcs_78_4[2] = {
+ {159, 5},
{0, 4},
};
-static arc arcs_79_5[1] = {
+static arc arcs_78_5[1] = {
{0, 5},
};
-static state states_79[6] = {
- {1, arcs_79_0},
- {1, arcs_79_1},
- {1, arcs_79_2},
- {1, arcs_79_3},
- {2, arcs_79_4},
- {1, arcs_79_5},
+static state states_78[6] = {
+ {1, arcs_78_0},
+ {1, arcs_78_1},
+ {1, arcs_78_2},
+ {1, arcs_78_3},
+ {2, arcs_78_4},
+ {1, arcs_78_5},
};
-static arc arcs_80_0[1] = {
- {91, 1},
+static arc arcs_79_0[1] = {
+ {87, 1},
};
-static arc arcs_80_1[1] = {
- {105, 2},
+static arc arcs_79_1[1] = {
+ {103, 2},
};
-static arc arcs_80_2[2] = {
- {161, 3},
+static arc arcs_79_2[2] = {
+ {159, 3},
{0, 2},
};
-static arc arcs_80_3[1] = {
+static arc arcs_79_3[1] = {
{0, 3},
};
-static state states_80[4] = {
- {1, arcs_80_0},
- {1, arcs_80_1},
- {2, arcs_80_2},
- {1, arcs_80_3},
+static state states_79[4] = {
+ {1, arcs_79_0},
+ {1, arcs_79_1},
+ {2, arcs_79_2},
+ {1, arcs_79_3},
};
-static arc arcs_81_0[1] = {
+static arc arcs_80_0[1] = {
{26, 1},
};
-static arc arcs_81_1[2] = {
+static arc arcs_80_1[2] = {
{27, 0},
{0, 1},
};
-static state states_81[2] = {
- {1, arcs_81_0},
- {2, arcs_81_1},
+static state states_80[2] = {
+ {1, arcs_80_0},
+ {2, arcs_80_1},
};
-static arc arcs_82_0[1] = {
+static arc arcs_81_0[1] = {
{19, 1},
};
-static arc arcs_82_1[1] = {
+static arc arcs_81_1[1] = {
{0, 1},
};
-static state states_82[2] = {
- {1, arcs_82_0},
- {1, arcs_82_1},
+static state states_81[2] = {
+ {1, arcs_81_0},
+ {1, arcs_81_1},
};
-static arc arcs_83_0[1] = {
- {165, 1},
+static arc arcs_82_0[1] = {
+ {163, 1},
};
-static arc arcs_83_1[2] = {
+static arc arcs_82_1[2] = {
{9, 2},
{0, 1},
};
-static arc arcs_83_2[1] = {
+static arc arcs_82_2[1] = {
{0, 2},
};
-static state states_83[3] = {
- {1, arcs_83_0},
- {2, arcs_83_1},
- {1, arcs_83_2},
+static state states_82[3] = {
+ {1, arcs_82_0},
+ {2, arcs_82_1},
+ {1, arcs_82_2},
};
-static dfa dfas[84] = {
+static dfa dfas[83] = {
{256, "single_input", 0, 3, states_0,
- "\004\050\014\000\000\000\000\025\074\005\023\310\011\020\004\000\140\010\311\040\040"},
+ "\004\050\014\000\000\000\200\012\236\202\201\054\001\004\001\000\030\102\062\010\010"},
{257, "file_input", 0, 2, states_1,
- "\204\050\014\000\000\000\000\025\074\005\023\310\011\020\004\000\140\010\311\040\040"},
+ "\204\050\014\000\000\000\200\012\236\202\201\054\001\004\001\000\030\102\062\010\010"},
{258, "eval_input", 0, 3, states_2,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\140\010\311\000\000"},
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\004\001\000\030\102\062\000\000"},
{259, "decorator", 0, 7, states_3,
"\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
{260, "decorators", 0, 2, states_4,
@@ -1806,39 +1773,39 @@ static dfa dfas[84] = {
{265, "fplist", 0, 3, states_9,
"\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
{266, "stmt", 0, 2, states_10,
- "\000\050\014\000\000\000\000\025\074\005\023\310\011\020\004\000\140\010\311\040\040"},
+ "\000\050\014\000\000\000\200\012\236\202\201\054\001\004\001\000\030\102\062\010\010"},
{267, "simple_stmt", 0, 4, states_11,
- "\000\040\010\000\000\000\000\025\074\005\023\000\000\020\004\000\140\010\311\000\040"},
+ "\000\040\010\000\000\000\200\012\236\202\001\000\000\004\001\000\030\102\062\000\010"},
{268, "small_stmt", 0, 2, states_12,
- "\000\040\010\000\000\000\000\025\074\005\023\000\000\020\004\000\140\010\311\000\040"},
+ "\000\040\010\000\000\000\200\012\236\202\001\000\000\004\001\000\030\102\062\000\010"},
{269, "expr_stmt", 0, 6, states_13,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\140\010\311\000\000"},
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\004\001\000\030\102\062\000\000"},
{270, "augassign", 0, 2, states_14,
- "\000\000\000\000\000\360\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+ "\000\000\000\000\000\370\177\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
{271, "print_stmt", 0, 9, states_15,
- "\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+ "\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
{272, "del_stmt", 0, 3, states_16,
- "\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+ "\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000"},
{273, "pass_stmt", 0, 2, states_17,
- "\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+ "\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000"},
{274, "flow_stmt", 0, 2, states_18,
- "\000\000\000\000\000\000\000\000\074\000\000\000\000\000\000\000\000\000\000\000\040"},
+ "\000\000\000\000\000\000\000\000\036\000\000\000\000\000\000\000\000\000\000\000\010"},
{275, "break_stmt", 0, 2, states_19,
- "\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000"},
+ "\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000"},
{276, "continue_stmt", 0, 2, states_20,
- "\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000"},
+ "\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000"},
{277, "return_stmt", 0, 3, states_21,
- "\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000"},
+ "\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000"},
{278, "yield_stmt", 0, 2, states_22,
- "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\040"},
+ "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\010"},
{279, "raise_stmt", 0, 7, states_23,
- "\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000"},
+ "\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000"},
{280, "import_stmt", 0, 2, states_24,
- "\000\000\000\000\000\000\000\000\000\005\000\000\000\000\000\000\000\000\000\000\000"},
+ "\000\000\000\000\000\000\000\000\200\002\000\000\000\000\000\000\000\000\000\000\000"},
{281, "import_name", 0, 3, states_25,
- "\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000"},
+ "\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000"},
{282, "import_from", 0, 8, states_26,
- "\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000"},
+ "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000"},
{283, "import_as_name", 0, 4, states_27,
"\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
{284, "dotted_as_name", 0, 4, states_28,
@@ -1850,126 +1817,124 @@ static dfa dfas[84] = {
{287, "dotted_name", 0, 2, states_31,
"\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
{288, "global_stmt", 0, 3, states_32,
+ "\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000"},
+ {289, "assert_stmt", 0, 5, states_33,
"\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000"},
- {289, "exec_stmt", 0, 7, states_33,
- "\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000"},
- {290, "assert_stmt", 0, 5, states_34,
- "\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000"},
- {291, "compound_stmt", 0, 2, states_35,
- "\000\010\004\000\000\000\000\000\000\000\000\310\011\000\000\000\000\000\000\040\000"},
- {292, "if_stmt", 0, 8, states_36,
+ {290, "compound_stmt", 0, 2, states_34,
+ "\000\010\004\000\000\000\000\000\000\000\200\054\001\000\000\000\000\000\000\010\000"},
+ {291, "if_stmt", 0, 8, states_35,
+ "\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000"},
+ {292, "while_stmt", 0, 8, states_36,
+ "\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000"},
+ {293, "for_stmt", 0, 10, states_37,
"\000\000\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000"},
- {293, "while_stmt", 0, 8, states_37,
- "\000\000\000\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000"},
- {294, "for_stmt", 0, 10, states_38,
- "\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000"},
- {295, "try_stmt", 0, 13, states_39,
+ {294, "try_stmt", 0, 13, states_38,
+ "\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000"},
+ {295, "with_stmt", 0, 6, states_39,
"\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000"},
- {296, "with_stmt", 0, 6, states_40,
+ {296, "with_var", 0, 3, states_40,
+ "\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000"},
+ {297, "except_clause", 0, 5, states_41,
"\000\000\000\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000"},
- {297, "with_var", 0, 3, states_41,
- "\000\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000\000"},
- {298, "except_clause", 0, 5, states_42,
- "\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000"},
- {299, "suite", 0, 5, states_43,
- "\004\040\010\000\000\000\000\025\074\005\023\000\000\020\004\000\140\010\311\000\040"},
- {300, "testlist_safe", 0, 5, states_44,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\140\010\311\000\000"},
- {301, "old_test", 0, 2, states_45,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\140\010\311\000\000"},
- {302, "old_lambdef", 0, 5, states_46,
- "\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000"},
- {303, "test", 0, 6, states_47,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\140\010\311\000\000"},
- {304, "or_test", 0, 2, states_48,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\004\000\140\010\311\000\000"},
- {305, "and_test", 0, 2, states_49,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\004\000\140\010\311\000\000"},
- {306, "not_test", 0, 3, states_50,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\004\000\140\010\311\000\000"},
- {307, "comparison", 0, 2, states_51,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\140\010\311\000\000"},
- {308, "comp_op", 0, 4, states_52,
- "\000\000\000\000\000\000\000\000\000\000\010\000\000\000\344\017\000\000\000\000\000"},
- {309, "expr", 0, 2, states_53,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\140\010\311\000\000"},
- {310, "xor_expr", 0, 2, states_54,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\140\010\311\000\000"},
- {311, "and_expr", 0, 2, states_55,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\140\010\311\000\000"},
- {312, "shift_expr", 0, 2, states_56,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\140\010\311\000\000"},
- {313, "arith_expr", 0, 2, states_57,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\140\010\311\000\000"},
- {314, "term", 0, 2, states_58,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\140\010\311\000\000"},
- {315, "factor", 0, 3, states_59,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\140\010\311\000\000"},
- {316, "power", 0, 4, states_60,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\311\000\000"},
- {317, "atom", 0, 9, states_61,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\311\000\000"},
- {318, "listmaker", 0, 5, states_62,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\140\010\311\000\000"},
- {319, "testlist_gexp", 0, 5, states_63,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\140\010\311\000\000"},
- {320, "lambdef", 0, 5, states_64,
- "\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000"},
- {321, "trailer", 0, 7, states_65,
- "\000\040\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\001\000\000"},
- {322, "subscriptlist", 0, 3, states_66,
- "\000\040\050\000\000\000\000\000\000\010\000\000\000\020\004\000\140\010\311\000\000"},
- {323, "subscript", 0, 7, states_67,
- "\000\040\050\000\000\000\000\000\000\010\000\000\000\020\004\000\140\010\311\000\000"},
- {324, "sliceop", 0, 3, states_68,
+ {298, "suite", 0, 5, states_42,
+ "\004\040\010\000\000\000\200\012\236\202\001\000\000\004\001\000\030\102\062\000\010"},
+ {299, "testlist_safe", 0, 5, states_43,
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\004\001\000\030\102\062\000\000"},
+ {300, "old_test", 0, 2, states_44,
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\004\001\000\030\102\062\000\000"},
+ {301, "old_lambdef", 0, 5, states_45,
+ "\000\000\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000"},
+ {302, "test", 0, 6, states_46,
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\004\001\000\030\102\062\000\000"},
+ {303, "or_test", 0, 2, states_47,
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\001\000\030\102\062\000\000"},
+ {304, "and_test", 0, 2, states_48,
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\001\000\030\102\062\000\000"},
+ {305, "not_test", 0, 3, states_49,
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\001\000\030\102\062\000\000"},
+ {306, "comparison", 0, 2, states_50,
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\030\102\062\000\000"},
+ {307, "comp_op", 0, 4, states_51,
+ "\000\000\000\000\000\000\000\000\000\000\000\020\000\000\371\003\000\000\000\000\000"},
+ {308, "expr", 0, 2, states_52,
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\030\102\062\000\000"},
+ {309, "xor_expr", 0, 2, states_53,
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\030\102\062\000\000"},
+ {310, "and_expr", 0, 2, states_54,
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\030\102\062\000\000"},
+ {311, "shift_expr", 0, 2, states_55,
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\030\102\062\000\000"},
+ {312, "arith_expr", 0, 2, states_56,
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\030\102\062\000\000"},
+ {313, "term", 0, 2, states_57,
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\030\102\062\000\000"},
+ {314, "factor", 0, 3, states_58,
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\030\102\062\000\000"},
+ {315, "power", 0, 4, states_59,
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\100\062\000\000"},
+ {316, "atom", 0, 9, states_60,
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\100\062\000\000"},
+ {317, "listmaker", 0, 5, states_61,
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\004\001\000\030\102\062\000\000"},
+ {318, "testlist_gexp", 0, 5, states_62,
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\004\001\000\030\102\062\000\000"},
+ {319, "lambdef", 0, 5, states_63,
+ "\000\000\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000"},
+ {320, "trailer", 0, 7, states_64,
+ "\000\040\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\100\000\000\000"},
+ {321, "subscriptlist", 0, 3, states_65,
+ "\000\040\050\000\000\000\000\000\000\004\000\000\000\004\001\000\030\102\062\000\000"},
+ {322, "subscript", 0, 7, states_66,
+ "\000\040\050\000\000\000\000\000\000\004\000\000\000\004\001\000\030\102\062\000\000"},
+ {323, "sliceop", 0, 3, states_67,
"\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
- {325, "exprlist", 0, 3, states_69,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\140\010\311\000\000"},
- {326, "testlist", 0, 3, states_70,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\140\010\311\000\000"},
- {327, "dictsetmaker", 0, 8, states_71,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\140\010\311\000\000"},
- {328, "classdef", 0, 8, states_72,
- "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\040\000"},
- {329, "arglist", 0, 8, states_73,
- "\000\040\010\060\000\000\000\000\000\000\000\000\000\020\004\000\140\010\311\000\000"},
- {330, "argument", 0, 4, states_74,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\140\010\311\000\000"},
- {331, "list_iter", 0, 2, states_75,
- "\000\000\000\000\000\000\000\000\000\000\000\210\000\000\000\000\000\000\000\000\000"},
- {332, "list_for", 0, 6, states_76,
- "\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000"},
- {333, "list_if", 0, 4, states_77,
+ {324, "exprlist", 0, 3, states_68,
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\030\102\062\000\000"},
+ {325, "testlist", 0, 3, states_69,
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\004\001\000\030\102\062\000\000"},
+ {326, "dictsetmaker", 0, 8, states_70,
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\004\001\000\030\102\062\000\000"},
+ {327, "classdef", 0, 8, states_71,
+ "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\010\000"},
+ {328, "arglist", 0, 8, states_72,
+ "\000\040\010\060\000\000\000\000\000\000\000\000\000\004\001\000\030\102\062\000\000"},
+ {329, "argument", 0, 4, states_73,
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\004\001\000\030\102\062\000\000"},
+ {330, "list_iter", 0, 2, states_74,
+ "\000\000\000\000\000\000\000\000\000\000\200\010\000\000\000\000\000\000\000\000\000"},
+ {331, "list_for", 0, 6, states_75,
"\000\000\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000"},
- {334, "gen_iter", 0, 2, states_78,
- "\000\000\000\000\000\000\000\000\000\000\000\210\000\000\000\000\000\000\000\000\000"},
- {335, "gen_for", 0, 6, states_79,
- "\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000"},
- {336, "gen_if", 0, 4, states_80,
+ {332, "list_if", 0, 4, states_76,
+ "\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000"},
+ {333, "gen_iter", 0, 2, states_77,
+ "\000\000\000\000\000\000\000\000\000\000\200\010\000\000\000\000\000\000\000\000\000"},
+ {334, "gen_for", 0, 6, states_78,
"\000\000\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000"},
- {337, "testlist1", 0, 2, states_81,
- "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\140\010\311\000\000"},
- {338, "encoding_decl", 0, 2, states_82,
+ {335, "gen_if", 0, 4, states_79,
+ "\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000"},
+ {336, "testlist1", 0, 2, states_80,
+ "\000\040\010\000\000\000\000\000\000\000\000\000\000\004\001\000\030\102\062\000\000"},
+ {337, "encoding_decl", 0, 2, states_81,
"\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
- {339, "yield_expr", 0, 3, states_83,
- "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\040"},
+ {338, "yield_expr", 0, 3, states_82,
+ "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\010"},
};
-static label labels[166] = {
+static label labels[164] = {
{0, "EMPTY"},
{256, 0},
{4, 0},
{267, 0},
- {291, 0},
+ {290, 0},
{257, 0},
{266, 0},
{0, 0},
{258, 0},
- {326, 0},
+ {325, 0},
{259, 0},
{50, 0},
{287, 0},
{7, 0},
- {329, 0},
+ {328, 0},
{8, 0},
{260, 0},
{261, 0},
@@ -1977,11 +1942,11 @@ static label labels[166] = {
{1, 0},
{262, 0},
{11, 0},
- {299, 0},
+ {298, 0},
{263, 0},
{264, 0},
{22, 0},
- {303, 0},
+ {302, 0},
{12, 0},
{16, 0},
{36, 0},
@@ -1996,9 +1961,8 @@ static label labels[166] = {
{280, 0},
{288, 0},
{289, 0},
- {290, 0},
{270, 0},
- {339, 0},
+ {338, 0},
{37, 0},
{38, 0},
{39, 0},
@@ -2014,7 +1978,7 @@ static label labels[166] = {
{1, "print"},
{35, 0},
{1, "del"},
- {325, 0},
+ {324, 0},
{1, "pass"},
{275, 0},
{276, 0},
@@ -2036,42 +2000,41 @@ static label labels[166] = {
{1, "as"},
{284, 0},
{1, "global"},
- {1, "exec"},
- {309, 0},
- {1, "in"},
{1, "assert"},
+ {291, 0},
{292, 0},
{293, 0},
{294, 0},
{295, 0},
- {296, 0},
- {328, 0},
+ {327, 0},
{1, "if"},
{1, "elif"},
{1, "else"},
{1, "while"},
{1, "for"},
+ {1, "in"},
{1, "try"},
- {298, 0},
+ {297, 0},
{1, "finally"},
{1, "with"},
- {297, 0},
+ {296, 0},
+ {308, 0},
{1, "except"},
{5, 0},
{6, 0},
+ {299, 0},
{300, 0},
+ {303, 0},
{301, 0},
- {304, 0},
- {302, 0},
{1, "lambda"},
- {320, 0},
- {305, 0},
+ {319, 0},
+ {304, 0},
{1, "or"},
- {306, 0},
+ {305, 0},
{1, "and"},
{1, "not"},
+ {306, 0},
{307, 0},
- {308, 0},
{20, 0},
{21, 0},
{28, 0},
@@ -2079,52 +2042,52 @@ static label labels[166] = {
{30, 0},
{29, 0},
{1, "is"},
- {310, 0},
+ {309, 0},
{18, 0},
- {311, 0},
+ {310, 0},
{33, 0},
- {312, 0},
+ {311, 0},
{19, 0},
- {313, 0},
+ {312, 0},
{34, 0},
- {314, 0},
+ {313, 0},
{14, 0},
{15, 0},
- {315, 0},
+ {314, 0},
{17, 0},
{24, 0},
{48, 0},
{32, 0},
+ {315, 0},
{316, 0},
- {317, 0},
- {321, 0},
- {319, 0},
- {9, 0},
+ {320, 0},
{318, 0},
+ {9, 0},
+ {317, 0},
{10, 0},
{26, 0},
- {327, 0},
+ {326, 0},
{27, 0},
{2, 0},
{3, 0},
- {332, 0},
- {335, 0},
+ {331, 0},
+ {334, 0},
+ {321, 0},
{322, 0},
{323, 0},
- {324, 0},
{1, "class"},
+ {329, 0},
{330, 0},
- {331, 0},
+ {332, 0},
{333, 0},
- {334, 0},
+ {335, 0},
{336, 0},
{337, 0},
- {338, 0},
{1, "yield"},
};
grammar _PyParser_Grammar = {
- 84,
+ 83,
dfas,
- {166, labels},
+ {164, labels},
256
};
diff --git a/Python/symtable.c b/Python/symtable.c
index 64eeb53..81020a9 100644
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -480,8 +480,7 @@ check_unoptimized(const PySTEntryObject* ste) {
"is a nested function");
switch (ste->ste_unoptimized) {
- case OPT_TOPLEVEL: /* exec / import * at top-level is fine */
- case OPT_EXEC: /* qualified exec is fine */
+ case OPT_TOPLEVEL: /* import * at top-level is fine */
return 1;
case OPT_IMPORT_STAR:
PyOS_snprintf(buf, sizeof(buf),
@@ -489,18 +488,6 @@ check_unoptimized(const PySTEntryObject* ste) {
"because it is %s",
PyString_AS_STRING(ste->ste_name), trailer);
break;
- case OPT_BARE_EXEC:
- PyOS_snprintf(buf, sizeof(buf),
- "unqualified exec is not allowed in function "
- "'%.100s' it %s",
- PyString_AS_STRING(ste->ste_name), trailer);
- break;
- default:
- PyOS_snprintf(buf, sizeof(buf),
- "function '%.100s' uses import * and bare exec, "
- "which are illegal because it %s",
- PyString_AS_STRING(ste->ste_name), trailer);
- break;
}
PyErr_SetString(PyExc_SyntaxError, buf);
@@ -1045,19 +1032,6 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
if (st->st_cur->ste_unoptimized && !st->st_cur->ste_opt_lineno)
st->st_cur->ste_opt_lineno = s->lineno;
break;
- case Exec_kind:
- VISIT(st, expr, s->v.Exec.body);
- if (!st->st_cur->ste_opt_lineno)
- st->st_cur->ste_opt_lineno = s->lineno;
- if (s->v.Exec.globals) {
- st->st_cur->ste_unoptimized |= OPT_EXEC;
- VISIT(st, expr, s->v.Exec.globals);
- if (s->v.Exec.locals)
- VISIT(st, expr, s->v.Exec.locals);
- } else {
- st->st_cur->ste_unoptimized |= OPT_BARE_EXEC;
- }
- break;
case Global_kind: {
int i;
asdl_seq *seq = s->v.Global.names;
diff --git a/Tools/compiler/ast.txt b/Tools/compiler/ast.txt
index 0db14d7..1f69e7e 100644
--- a/Tools/compiler/ast.txt
+++ b/Tools/compiler/ast.txt
@@ -23,7 +23,6 @@ While: test, body, else_&
With: expr, vars&, body
If: tests!, else_&
IfExp: test, then, else_
-Exec: expr, locals&, globals&
From: modname*, names*, level*
Import: names*
Raise: expr1&, expr2&, expr3&
diff --git a/Tools/modulator/modulator.py b/Tools/modulator/modulator.py
index 3e06bc2..a06306b 100755
--- a/Tools/modulator/modulator.py
+++ b/Tools/modulator/modulator.py
@@ -126,7 +126,7 @@ class UI:
fp = open(fn, 'w')
try:
- exec pycode
+ exec(pycode)
except:
message('An error occurred:-)')
return
@@ -371,7 +371,7 @@ def main():
fp = open(sys.argv[1])
pycode = fp.read()
try:
- exec pycode
+ exec(pycode)
except:
sys.stderr.write('An error occurred:-)\n')
sys.exit(1)
diff --git a/Tools/scripts/fixdiv.py b/Tools/scripts/fixdiv.py
index 2bbd3d5..7e1ed0b 100755
--- a/Tools/scripts/fixdiv.py
+++ b/Tools/scripts/fixdiv.py
@@ -113,7 +113,7 @@ Notes:
future division statement.
- Warnings may be issued for code not read from a file, but executed
- using an exec statement or the eval() function. These may have
+ using the exec() or eval() functions. These may have
<string> in the filename position, in which case the fixdiv script
will attempt and fail to open a file named '<string>' and issue a
warning about this failure; or these may be reported as 'Phantom'
diff --git a/Tools/scripts/h2py.py b/Tools/scripts/h2py.py
index 63e7336..f4b8306 100755
--- a/Tools/scripts/h2py.py
+++ b/Tools/scripts/h2py.py
@@ -130,7 +130,7 @@ def process(fp, outfp, env = {}):
ok = 0
stmt = '%s = %s\n' % (name, body.strip())
try:
- exec stmt in env
+ exec(stmt, env)
except:
sys.stderr.write('Skipping: %s' % stmt)
else:
@@ -142,7 +142,7 @@ def process(fp, outfp, env = {}):
body = pytify(body)
stmt = 'def %s(%s): return %s\n' % (macro, arg, body)
try:
- exec stmt in env
+ exec(stmt, env)
except:
sys.stderr.write('Skipping: %s' % stmt)
else: