Skip to content

Commit eb5ce32

Browse files
bpo-38872: Document exec symbol for codeop.compile_command (GH-20047) (GH-20098)
* Document exec symbol for codeop.compile_command * Remove extra statements Co-authored-by: nanjekyejoannah <[email protected]> (cherry picked from commit 7ba1f75) Co-authored-by: Joannah Nanjekye <[email protected]> Co-authored-by: Joannah Nanjekye <[email protected]>
1 parent 35b8a4d commit eb5ce32

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

Doc/library/code.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ build applications which provide an interactive interpreter prompt.
5656

5757
*source* is the source string; *filename* is the optional filename from which
5858
source was read, defaulting to ``'<input>'``; and *symbol* is the optional
59-
grammar start symbol, which should be either ``'single'`` (the default) or
60-
``'eval'``.
59+
grammar start symbol, which should be ``'single'`` (the default), ``'eval'``
60+
or ``'exec'``.
6161

6262
Returns a code object (the same as ``compile(source, filename, symbol)``) if the
6363
command is complete and valid; ``None`` if the command is incomplete; raises

Doc/library/codeop.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ To do just the former:
4343
:exc:`OverflowError` or :exc:`ValueError` if there is an invalid literal.
4444

4545
The *symbol* argument determines whether *source* is compiled as a statement
46-
(``'single'``, the default) or as an :term:`expression` (``'eval'``). Any
47-
other value will cause :exc:`ValueError` to be raised.
46+
(``'single'``, the default), as a sequence of statements (``'exec'``) or
47+
as an :term:`expression` (``'eval'``). Any other value will
48+
cause :exc:`ValueError` to be raised.
4849

4950
.. note::
5051

Lib/codeop.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ def compile_command(source, filename="<input>", symbol="single"):
112112
source -- the source string; may contain \n characters
113113
filename -- optional filename from which source was read; default
114114
"<input>"
115-
symbol -- optional grammar start symbol; "single" (default) or "eval"
115+
symbol -- optional grammar start symbol; "single" (default), "exec"
116+
or "eval"
116117
117118
Return value / exceptions raised:
118119

0 commit comments

Comments
 (0)