mirror of
https://github.com/progval/Limnoria.git
synced 2025-04-27 05:21:09 -05:00
math_evaluator: Add Python 3.14 support
This commit is contained in:
parent
54c0980978
commit
9963fe3f7b
@ -154,8 +154,16 @@ class SafeEvalVisitor(ast.NodeVisitor):
|
|||||||
return self.visit(node.body)
|
return self.visit(node.body)
|
||||||
|
|
||||||
def visit_Num(self, node):
|
def visit_Num(self, node):
|
||||||
|
"""Python < 3.14 only"""
|
||||||
return self._convert_num(node.n)
|
return self._convert_num(node.n)
|
||||||
|
|
||||||
|
def visit_Constant(self, node):
|
||||||
|
"""Python >= 3.14 only"""
|
||||||
|
if type(node.value) in (float, complex, int):
|
||||||
|
return self._convert_num(node.value)
|
||||||
|
else:
|
||||||
|
raise InvalidNode('illegal constant %s' % node.value)
|
||||||
|
|
||||||
def visit_Name(self, node):
|
def visit_Name(self, node):
|
||||||
id_ = node.id.lower()
|
id_ = node.id.lower()
|
||||||
if id_ in self._env:
|
if id_ in self._env:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user