mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-12-23 23:57:51 -05:00
calculate_math_string: support Python 3.14 and newer
Switch to ast.Constant, ast.Num was deprecated in Python 3.8 and removed in Python 3.14. > Changed in version 3.8: Class ast.Constant is now used for all constants. > > Deprecated since version 3.8: Old classes ast.Num, ast.Str, ast.Bytes, > ast.NameConstant and ast.Ellipsis are still available, but they will be > removed in future Python releases. In the meanwhile, instantiating them > will return an instance of a different class. https://docs.python.org/3.14/library/ast.html#ast.AST.end_col_offset
This commit is contained in:
@@ -4776,8 +4776,8 @@ def calculate_math_string(expr):
|
||||
}
|
||||
|
||||
def execute_ast(node):
|
||||
if isinstance(node, ast.Num): # <number>
|
||||
return node.n
|
||||
if isinstance(node, ast.Constant): # <number>
|
||||
return node.value
|
||||
elif isinstance(node, ast.BinOp): # <left> <operator> <right>
|
||||
return ops[type(node.op)](execute_ast(node.left),
|
||||
execute_ast(node.right))
|
||||
|
||||
Reference in New Issue
Block a user