Skip to content

Commit c1203b7

Browse files
bpo-38872: Document exec symbol for codeop.compile_command (GH-20047) (#20099)
* Document exec symbol for codeop.compile_command * Remove extra statements Co-authored-by: nanjekyejoannah <joannah.nanjekye@ibm.com> (cherry picked from commit 7ba1f75) Co-authored-by: Joannah Nanjekye <33177550+nanjekyejoannah@users.noreply.github.com> Co-authored-by: Joannah Nanjekye <33177550+nanjekyejoannah@users.noreply.github.com>
1 parent 61b49a0 commit c1203b7

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

Doc/library/code.rst

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 2 additions & 1 deletion
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy