From 44da3236621dee35c43aecf7cce4347be00147ee Mon Sep 17 00:00:00 2001 From: Daniel Fairhead Date: Sat, 2 Nov 2024 10:18:02 +0000 Subject: [PATCH] fix getattr for ast deprecated bits in 3.14 --- simpleeval.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/simpleeval.py b/simpleeval.py index 60b7fef..885a760 100644 --- a/simpleeval.py +++ b/simpleeval.py @@ -386,13 +386,13 @@ def __init__(self, operators=None, functions=None, names=None): warnings.simplefilter("ignore") # py3.12 deprecated ast.Num, ast.Str, ast.NameConstant # https://docs.python.org/3.12/whatsnew/3.12.html#deprecated - if Num := getattr(ast, "Num"): + if Num := getattr(ast, "Num", None): self.nodes[Num] = self._eval_num - if Str := getattr(ast, "Str"): + if Str := getattr(ast, "Str", None): self.nodes[Str] = self._eval_str - if NameConstant := getattr(ast, "NameConstant"): + if NameConstant := getattr(ast, "NameConstant", None): self.nodes[NameConstant] = self._eval_constant # Defaults: