2121from typing import Any , Callable
2222
2323from . import Image , _imagingmath
24- from ._deprecate import deprecate
2524
2625
2726class _Operand :
@@ -233,11 +232,7 @@ def imagemath_convert(self: _Operand, mode: str) -> _Operand:
233232}
234233
235234
236- def lambda_eval (
237- expression : Callable [[dict [str , Any ]], Any ],
238- options : dict [str , Any ] = {},
239- ** kw : Any ,
240- ) -> Any :
235+ def lambda_eval (expression : Callable [[dict [str , Any ]], Any ], ** kw : Any ) -> Any :
241236 """
242237 Returns the result of an image function.
243238
@@ -246,23 +241,13 @@ def lambda_eval(
246241 :py:func:`~PIL.Image.merge` function.
247242
248243 :param expression: A function that receives a dictionary.
249- :param options: Values to add to the function's dictionary. Deprecated.
250- You can instead use one or more keyword arguments.
251244 :param **kw: Values to add to the function's dictionary.
252245 :return: The expression result. This is usually an image object, but can
253246 also be an integer, a floating point value, or a pixel tuple,
254247 depending on the expression.
255248 """
256249
257- if options :
258- deprecate (
259- "ImageMath.lambda_eval options" ,
260- 12 ,
261- "ImageMath.lambda_eval keyword arguments" ,
262- )
263-
264250 args : dict [str , Any ] = ops .copy ()
265- args .update (options )
266251 args .update (kw )
267252 for k , v in args .items ():
268253 if isinstance (v , Image .Image ):
@@ -275,11 +260,7 @@ def lambda_eval(
275260 return out
276261
277262
278- def unsafe_eval (
279- expression : str ,
280- options : dict [str , Any ] = {},
281- ** kw : Any ,
282- ) -> Any :
263+ def unsafe_eval (expression : str , ** kw : Any ) -> Any :
283264 """
284265 Evaluates an image expression. This uses Python's ``eval()`` function to process
285266 the expression string, and carries the security risks of doing so. It is not
@@ -291,29 +272,19 @@ def unsafe_eval(
291272 :py:func:`~PIL.Image.merge` function.
292273
293274 :param expression: A string containing a Python-style expression.
294- :param options: Values to add to the evaluation context. Deprecated.
295- You can instead use one or more keyword arguments.
296275 :param **kw: Values to add to the evaluation context.
297276 :return: The evaluated expression. This is usually an image object, but can
298277 also be an integer, a floating point value, or a pixel tuple,
299278 depending on the expression.
300279 """
301280
302- if options :
303- deprecate (
304- "ImageMath.unsafe_eval options" ,
305- 12 ,
306- "ImageMath.unsafe_eval keyword arguments" ,
307- )
308-
309281 # build execution namespace
310282 args : dict [str , Any ] = ops .copy ()
311- for k in [ * options , * kw ] :
283+ for k in kw :
312284 if "__" in k or hasattr (builtins , k ):
313285 msg = f"'{ k } ' not allowed"
314286 raise ValueError (msg )
315287
316- args .update (options )
317288 args .update (kw )
318289 for k , v in args .items ():
319290 if isinstance (v , Image .Image ):
@@ -337,32 +308,3 @@ def scan(code: CodeType) -> None:
337308 return out .im
338309 except AttributeError :
339310 return out
340-
341-
342- def eval (
343- expression : str ,
344- _dict : dict [str , Any ] = {},
345- ** kw : Any ,
346- ) -> Any :
347- """
348- Evaluates an image expression.
349-
350- Deprecated. Use lambda_eval() or unsafe_eval() instead.
351-
352- :param expression: A string containing a Python-style expression.
353- :param _dict: Values to add to the evaluation context. You
354- can either use a dictionary, or one or more keyword
355- arguments.
356- :return: The evaluated expression. This is usually an image object, but can
357- also be an integer, a floating point value, or a pixel tuple,
358- depending on the expression.
359-
360- .. deprecated:: 10.3.0
361- """
362-
363- deprecate (
364- "ImageMath.eval" ,
365- 12 ,
366- "ImageMath.lambda_eval or ImageMath.unsafe_eval" ,
367- )
368- return unsafe_eval (expression , _dict , ** kw )
0 commit comments