Skip to content
Open
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
10 changes: 5 additions & 5 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
*mode* argument, :func:`eval`\'s return value will be ``None``.
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``.

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 on lines +644 to 645
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If the given source is a string or a bytes-like object, then leading and trailing spaces and tabs
are stripped.
If the given source is a string or a bytes-like object, then leading
and trailing spaces and tabs are stripped.


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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
a string, a bytes-like object or a code object. If it is a string or a bytes-like object, it 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

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