bpo-38872: Document exec symbol for codeop.compile_command (GH-20047) · python/cpython@7ba1f75 (original) (raw)

3 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -56,8 +56,8 @@ build applications which provide an interactive interpreter prompt.
56 56
57 57 *source* is the source string; *filename* is the optional filename from which
58 58 source was read, defaulting to ``''``; 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'``.
61 61
62 62 Returns a code object (the same as ``compile(source, filename, symbol)``) if the
63 63 command is complete and valid; ``None`` if the command is incomplete; raises
Original file line number Diff line number Diff line change
@@ -43,8 +43,9 @@ To do just the former:
43 43 :exc:`OverflowError` or :exc:`ValueError` if there is an invalid literal.
44 44
45 45 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.
48 49
49 50 .. note::
50 51
Original file line number Diff line number Diff line change
@@ -112,7 +112,8 @@ def compile_command(source, filename="", symbol="single"):
112 112 source -- the source string; may contain \n characters
113 113 filename -- optional filename from which source was read; default
114 114 ""
115 - symbol -- optional grammar start symbol; "single" (default) or "eval"
115 + symbol -- optional grammar start symbol; "single" (default), "exec"
116 + or "eval"
116 117
117 118 Return value / exceptions raised:
118 119