Skip to content

Commit 44da323

Browse files
committed
fix getattr for ast deprecated bits in 3.14
1 parent d65091a commit 44da323

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

simpleeval.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,13 @@ def __init__(self, operators=None, functions=None, names=None):
386386
warnings.simplefilter("ignore")
387387
# py3.12 deprecated ast.Num, ast.Str, ast.NameConstant
388388
# https://docs.python.org/3.12/whatsnew/3.12.html#deprecated
389-
if Num := getattr(ast, "Num"):
389+
if Num := getattr(ast, "Num", None):
390390
self.nodes[Num] = self._eval_num
391391

392-
if Str := getattr(ast, "Str"):
392+
if Str := getattr(ast, "Str", None):
393393
self.nodes[Str] = self._eval_str
394394

395-
if NameConstant := getattr(ast, "NameConstant"):
395+
if NameConstant := getattr(ast, "NameConstant", None):
396396
self.nodes[NameConstant] = self._eval_constant
397397

398398
# Defaults:

0 commit comments

Comments
 (0)