Skip to content

Commit 91fa393

Browse files
Merge pull request #1157 from douglasjacobsen/avoid-deprecated-ast-attributes
Avoid using deprecated ast attributes
2 parents ee34b01 + 8a05b6b commit 91fa393

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/ramble/ramble/expander.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -839,16 +839,16 @@ def eval_math(self, node):
839839
others will generate integers (if the inputs are integers).
840840
"""
841841
try:
842-
if isinstance(node, ast.Num):
843-
return self._ast_num(node)
844-
elif isinstance(node, ast.Constant):
842+
if hasattr(ast, "Constant") and isinstance(node, ast.Constant):
845843
return self._ast_constant(node)
844+
elif hasattr(ast, "Num") and isinstance(node, ast.Num): # Deprecated, removed in 3.14
845+
return self._ast_num(node)
846846
elif isinstance(node, ast.Name):
847847
return self._ast_name(node)
848848
# TODO: Remove when we drop support for 3.6
849849
# DEPRECATED: Remove due to python 3.8
850850
# See: https://docs.python.org/3/library/ast.html#node-classes
851-
elif isinstance(node, ast.Str):
851+
elif hasattr(ast, "Str") and isinstance(node, ast.Str): # Deprecated, removed in 3.14
852852
return node.s
853853
elif isinstance(node, ast.Attribute):
854854
return self._ast_attr(node)

0 commit comments

Comments
 (0)