Skip to content

Commit

Permalink
Name as 'options' in lambda_eval and unsafe_eval, but '_dict' in depr…
Browse files Browse the repository at this point in the history
…ecated eval
  • Loading branch information
hugovk committed Apr 1, 2024
1 parent 8f3860c commit f5eeeac
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/PIL/ImageMath.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def imagemath_convert(self: _Operand, mode: str) -> _Operand:

def lambda_eval(
expression: Callable[[dict[str, Any]], Any],
_dict: dict[str, Any] = {},
options: dict[str, Any] = {},
**kw: Any,
) -> Any:
"""
Expand All @@ -258,7 +258,7 @@ def lambda_eval(
"""

args: dict[str, Any] = ops.copy()
args.update(_dict)
args.update(options)
args.update(kw)
for k, v in args.items():
if hasattr(v, "im"):
Expand All @@ -273,7 +273,7 @@ def lambda_eval(

def unsafe_eval(
expression: str,
_dict: dict[str, Any] = {},
options: dict[str, Any] = {},
**kw: Any,
) -> Any:
"""
Expand All @@ -297,12 +297,12 @@ def unsafe_eval(

# build execution namespace
args: dict[str, Any] = ops.copy()
for k in list(_dict.keys()) + list(kw.keys()):
for k in list(options.keys()) + list(kw.keys()):
if "__" in k or hasattr(builtins, k):
msg = f"'{k}' not allowed"
raise ValueError(msg)

args.update(_dict)
args.update(options)
args.update(kw)
for k, v in args.items():
if hasattr(v, "im"):
Expand Down Expand Up @@ -339,9 +339,9 @@ def eval(
Deprecated. Use lambda_eval() or unsafe_eval() instead.
:param expression: A string containing a Python-style expression.
:param options: Values to add to the evaluation context. You
can either use a dictionary, or one or more keyword
arguments.
:param _dict: Values to add to the evaluation context. You
can either use a dictionary, or one or more keyword
arguments.
:return: The evaluated expression. This is usually an image object, but can
also be an integer, a floating point value, or a pixel tuple,
depending on the expression.
Expand Down

0 comments on commit f5eeeac

Please sign in to comment.