8000 gh-118633: Add warning regarding the unsafe usage of eval and exec by DanielRuf · Pull Request #118437 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-118633: Add warning regarding the unsafe usage of eval and exec #118437

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

Merged
merged 7 commits into from
Oct 30, 2024
Merged
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: 10 additions & 0 deletions Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,11 @@ are always available. They are listed here in alphabetical order.
:returns: The result of the evaluated expression.
:raises: Syntax errors are reported as exceptions.

.. warning::

This function executes arbitrary code. Calling it with
user-supplied input may lead to security vulnerabilities.

The *expression* argument is parsed and evaluated as a Python expression
(technically speaking, a condition list) using the *globals* and *locals*
dictionaries as global and local namespace. If the *globals* dictionary is
Expand Down Expand Up @@ -591,6 +596,11 @@ are always available. They are listed here in alphabetical order.

.. function:: exec(source, /, globals=None, locals=None, *, closure=None)

.. warning::

This function executes arbitrary code. Calling it with
user-supplied input may 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 suite of Python statements which is then executed (unless a syntax error
Expand Down
Loading
0