Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 70fcdb8

Browse files
committed
Document general mappings for the locals argument for exec and execfile().
1 parent a57ec93 commit 70fcdb8

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

Doc/lib/libfuncs.tex

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -343,13 +343,14 @@ \section{Built-in Functions \label{built-in-funcs}}
343343
and does not create a new module.\footnote{It is used relatively
344344
rarely so does not warrant being made into a statement.}
345345

346-
The arguments are a file name and two optional dictionaries. The
347-
file is parsed and evaluated as a sequence of Python statements
348-
(similarly to a module) using the \var{globals} and \var{locals}
349-
dictionaries as global and local namespace. If the \var{locals}
350-
dictionary is omitted it defaults to the \var{globals} dictionary.
351-
If both dictionaries are omitted, the expression is executed in the
352-
environment where \function{execfile()} is called. The return value is
346+
The arguments are a file name and two optional dictionaries. The file is
347+
parsed and evaluated as a sequence of Python statements (similarly to a
348+
module) using the \var{globals} and \var{locals} dictionaries as global and
349+
local namespace. If provided, \var{locals} can be any mapping object.
350+
\versionchanged[formerly \var{locals} was required to be a dictionary]{2.4}
351+
If the \var{locals} dictionary is omitted it defaults to the \var{globals}
352+
dictionary. If both dictionaries are omitted, the expression is executed in
353+
the environment where \function{execfile()} is called. The return value is
353354
\code{None}.
354355

355356
\warning{The default \var{locals} act as described for function

Doc/ref/ref6.tex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -873,8 +873,9 @@ \section{The \keyword{exec} statement \label{exec}}
873873
in the current scope. If only the first expression after \keyword{in}
874874
is specified, it should be a dictionary, which will be used for both
875875
the global and the local variables. If two expressions are given,
876-
both must be dictionaries and they are used for the global and local
877-
variables, respectively.
876+
they are used for the global and local variables, respectively.
877+
If provided, \var{locals} can be any mapping object.
878+
\versionchanged[formerly \var{locals} was required to be a dictionary]{2.4}
878879
879880
As a side effect, an implementation may insert additional keys into
880881
the dictionaries given besides those corresponding to variable names

0 commit comments

Comments
 (0)