Skip to content

Deprecate eval(), replacing it with lambda_eval() and unsafe_eval() #7927

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 6 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Removed "In the current version"
  • Loading branch information
radarhere authored and hugovk committed Apr 1, 2024
commit a7e82cbe9a2ecc17311d4d69091992a741360677
13 changes: 6 additions & 7 deletions docs/reference/ImageMath.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
The :py:mod:`~PIL.ImageMath` module can be used to evaluate “image expressions”, that
can take a number of images and generate a result.

In the current version, :py:mod:`~PIL.ImageMath` only supports single-layer images. To
process multi-band images, use the :py:meth:`~PIL.Image.Image.split` method or
:py:func:`~PIL.Image.merge` function.
:py:mod:`~PIL.ImageMath` only supports single-layer images. To process multi-band
images, use the :py:meth:`~PIL.Image.Image.split` method or :py:func:`~PIL.Image.merge`
function.

Example: Using the :py:mod:`~PIL.ImageMath` module
--------------------------------------------------
Expand Down Expand Up @@ -51,10 +51,9 @@ Example: Using the :py:mod:`~PIL.ImageMath` module
recommended to process expressions without considering this.
:py:meth:`~lambda_eval` is a more secure alternative.

In the current version, :py:mod:`~PIL.ImageMath` only supports
single-layer images. To process multi-band images, use the
:py:meth:`~PIL.Image.Image.split` method or :py:func:`~PIL.Image.merge`
function.
:py:mod:`~PIL.ImageMath` only supports single-layer images. To process multi-band
images, use the :py:meth:`~PIL.Image.Image.split` method or
:py:func:`~PIL.Image.merge` function.

:param expression: A string which uses the standard Python expression
syntax. In addition to the standard operators, you can
Expand Down
14 changes: 6 additions & 8 deletions src/PIL/ImageMath.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,9 @@ def lambda_eval(expression: Callable[[dict[str, Any]], Any],
"""
Returns the result of an image function.

In the current version, :py:mod:`~PIL.ImageMath` only supports
single-layer images. To process multi-band images, use the
:py:meth:`~PIL.Image.Image.split` method or :py:func:`~PIL.Image.merge`
function.
:py:mod:`~PIL.ImageMath` only supports single-layer images. To process multi-band
images, use the :py:meth:`~PIL.Image.Image.split` method or
:py:func:`~PIL.Image.merge` function.

:param expression: A function that receives a dictionary.
:param options: Values to add to the function's dictionary. You
Expand Down Expand Up @@ -281,10 +280,9 @@ def unsafe_eval(
recommended to process expressions without considering this.
:py:meth:`~lambda_eval` is a more secure alternative.

In the current version, :py:mod:`~PIL.ImageMath` only supports
single-layer images. To process multi-band images, use the
:py:meth:`~PIL.Image.Image.split` method or :py:func:`~PIL.Image.merge`
function.
:py:mod:`~PIL.ImageMath` only supports single-layer images. To process multi-band
images, use the :py:meth:`~PIL.Image.Image.split` method or
:py:func:`~PIL.Image.merge` function.

:param expression: A string containing a Python-style expression.
:param options: Values to add to the evaluation context. You
Expand Down