From 2e4a73342698c5dc013ce72bcf5f7619c8fb1107 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Fri, 18 Oct 2024 23:42:52 +0200 Subject: [PATCH] math_evaluator: Add Python 3.14 support --- src/utils/math_evaluator.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/utils/math_evaluator.py b/src/utils/math_evaluator.py index b7ef34027..ff04009ab 100644 --- a/src/utils/math_evaluator.py +++ b/src/utils/math_evaluator.py @@ -154,8 +154,16 @@ def visit_Expression(self, node): return self.visit(node.body) def visit_Num(self, node): + """Python < 3.14 only""" 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): id_ = node.id.lower() if id_ in self._env: