Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-38872: Document exec symbol for codeop.compile_command #20047

Merged
merged 2 commits into from
May 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Doc/library/code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ build applications which provide an interactive interpreter prompt.

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

Returns a code object (the same as ``compile(source, filename, symbol)``) if the
command is complete and valid; ``None`` if the command is incomplete; raises
Expand Down
5 changes: 3 additions & 2 deletions Doc/library/codeop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ To do just the former:
:exc:`OverflowError` or :exc:`ValueError` if there is an invalid literal.

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

.. note::

Expand Down
3 changes: 2 additions & 1 deletion Lib/codeop.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ def compile_command(source, filename="<input>", symbol="single"):
source -- the source string; may contain \n characters
filename -- optional filename from which source was read; default
"<input>"
symbol -- optional grammar start symbol; "single" (default) or "eval"
symbol -- optional grammar start symbol; "single" (default), "exec"
or "eval"

Return value / exceptions raised:

Expand Down