From fa1d5c78eba1b83dc043c59b1c26d74559de0513 Mon Sep 17 00:00:00 2001 From: Alexandros Nikolaos Ziogas Date: Sun, 8 Oct 2023 12:23:34 +0200 Subject: [PATCH] Check for ast.Num predicated by Python < 3.8. --- dace/codegen/cppunparse.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dace/codegen/cppunparse.py b/dace/codegen/cppunparse.py index 2b1328ca8b..58d4b2cb66 100644 --- a/dace/codegen/cppunparse.py +++ b/dace/codegen/cppunparse.py @@ -985,7 +985,9 @@ def _Attribute(self, t): # Special case: 3.__abs__() is a syntax error, so if t.value # is an integer literal then we need to either parenthesize # it or add an extra space to get 3 .__abs__(). - if (isinstance(t.value, (ast.Num, ast.Constant)) and isinstance(t.value.n, int)): + if isinstance(t.value, ast.Constant) and isinstance(t.value.value, int): + self.write(" ") + elif sys.version_info < (3, 8) and isinstance(t.value, ast.Num) and isinstance(t.value.n, int): self.write(" ") if (isinstance(t.value, ast.Name) and t.value.id in ('dace', 'dace::math', 'dace::cmath')): self.write("::")