Skip to content

Commit

Permalink
fix getattr for ast deprecated bits in 3.14
Browse files Browse the repository at this point in the history
  • Loading branch information
danthedeckie committed Nov 2, 2024
1 parent d65091a commit 44da323
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions simpleeval.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 44da323

Please sign in to comment.