mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 02:06:18 +03:00
Name as 'options' in lambda_eval and unsafe_eval, but '_dict' in deprecated eval
This commit is contained in:
parent
8f3860c29b
commit
f5eeeacf75
|
@ -238,7 +238,7 @@ ops = {
|
||||||
|
|
||||||
def lambda_eval(
|
def lambda_eval(
|
||||||
expression: Callable[[dict[str, Any]], Any],
|
expression: Callable[[dict[str, Any]], Any],
|
||||||
_dict: dict[str, Any] = {},
|
options: dict[str, Any] = {},
|
||||||
**kw: Any,
|
**kw: Any,
|
||||||
) -> Any:
|
) -> Any:
|
||||||
"""
|
"""
|
||||||
|
@ -258,7 +258,7 @@ def lambda_eval(
|
||||||
"""
|
"""
|
||||||
|
|
||||||
args: dict[str, Any] = ops.copy()
|
args: dict[str, Any] = ops.copy()
|
||||||
args.update(_dict)
|
args.update(options)
|
||||||
args.update(kw)
|
args.update(kw)
|
||||||
for k, v in args.items():
|
for k, v in args.items():
|
||||||
if hasattr(v, "im"):
|
if hasattr(v, "im"):
|
||||||
|
@ -273,7 +273,7 @@ def lambda_eval(
|
||||||
|
|
||||||
def unsafe_eval(
|
def unsafe_eval(
|
||||||
expression: str,
|
expression: str,
|
||||||
_dict: dict[str, Any] = {},
|
options: dict[str, Any] = {},
|
||||||
**kw: Any,
|
**kw: Any,
|
||||||
) -> Any:
|
) -> Any:
|
||||||
"""
|
"""
|
||||||
|
@ -297,12 +297,12 @@ def unsafe_eval(
|
||||||
|
|
||||||
# build execution namespace
|
# build execution namespace
|
||||||
args: dict[str, Any] = ops.copy()
|
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):
|
if "__" in k or hasattr(builtins, k):
|
||||||
msg = f"'{k}' not allowed"
|
msg = f"'{k}' not allowed"
|
||||||
raise ValueError(msg)
|
raise ValueError(msg)
|
||||||
|
|
||||||
args.update(_dict)
|
args.update(options)
|
||||||
args.update(kw)
|
args.update(kw)
|
||||||
for k, v in args.items():
|
for k, v in args.items():
|
||||||
if hasattr(v, "im"):
|
if hasattr(v, "im"):
|
||||||
|
@ -339,7 +339,7 @@ def eval(
|
||||||
Deprecated. Use lambda_eval() or unsafe_eval() instead.
|
Deprecated. Use lambda_eval() or unsafe_eval() instead.
|
||||||
|
|
||||||
:param expression: A string containing a Python-style expression.
|
:param expression: A string containing a Python-style expression.
|
||||||
:param options: Values to add to the evaluation context. You
|
:param _dict: Values to add to the evaluation context. You
|
||||||
can either use a dictionary, or one or more keyword
|
can either use a dictionary, or one or more keyword
|
||||||
arguments.
|
arguments.
|
||||||
:return: The evaluated expression. This is usually an image object, but can
|
:return: The evaluated expression. This is usually an image object, but can
|
||||||
|
|
Loading…
Reference in New Issue
Block a user