Skip to content
Open
Changes from 2 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
8 changes: 4 additions & 4 deletions Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ are always available. They are listed here in alphabetical order.

:param source:
A Python expression.
:type source: :class:`str` | :ref:`code object <code-objects>`
:type source: :class:`str` | :term:`bytes-like object` | :ref:`code object <code-objects>`

:param globals:
The global namespace (default: ``None``).
Expand Down Expand Up @@ -633,15 +633,15 @@ are always available. They are listed here in alphabetical order.

This function can also be used to execute arbitrary code objects (such as
those created by :func:`compile`). In this case, pass a code object instead
of a string. If the code object has been compiled with ``'exec'`` as the
of a string or a bytes-like object. If the code object has been compiled with ``'exec'`` as the
*mode* argument, :func:`eval`\'s return value will be ``None``.
Comment thread
goroshirow marked this conversation as resolved.
Outdated

Hints: dynamic execution of statements is supported by the :func:`exec`
function. The :func:`globals` and :func:`locals` functions
return the current global and local dictionary, respectively, which may be
useful to pass around for use by :func:`eval` or :func:`exec`.

If the given source is a string, then leading and trailing spaces and tabs
If the given source is a string or a bytes-like object, then leading and trailing spaces and tabs
are stripped.
Comment thread
goroshirow marked this conversation as resolved.
Outdated

See :func:`ast.literal_eval` for a function to evaluate strings
Expand Down Expand Up @@ -675,7 +675,7 @@ are always available. They are listed here in alphabetical order.
untrusted user-supplied input will lead to security vulnerabilities.

This function supports dynamic execution of Python code. *source* must be
either a string or a code object. If it is a string, the string is parsed as
a string, a bytes-like object or a code object. If it is a string or a bytes-like object, it is parsed as
Comment thread
goroshirow marked this conversation as resolved.
Outdated
a suite of Python statements which is then executed (unless a syntax error
occurs). [#]_ If it is a code object, it is simply executed. In all cases,
the code that's executed is expected to be valid as file input (see the
Expand Down
Loading