From 23707a12ea33c2747726c9d1d5917f33cbb9d3ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Tue, 2 Aug 2022 21:35:33 +0200 Subject: [PATCH] tests: fix scripting API tests with Python 3.8 --- tests/scripts/python/unparse.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/scripts/python/unparse.py b/tests/scripts/python/unparse.py index d387cd906..9fc24ee4a 100755 --- a/tests/scripts/python/unparse.py +++ b/tests/scripts/python/unparse.py @@ -255,6 +255,11 @@ class UnparsePython(object): self.unindent, ) + def _ast_index(self, node): + """Add an AST Subscript in output.""" + # note: deprecated since Python 3.9 + self.add(node.value) + def _ast_import(self, node): """Add an AST Import in output.""" # ignore import @@ -272,7 +277,7 @@ class UnparsePython(object): def _ast_num(self, node): """Add an AST Num in output.""" # note: deprecated since Python 3.8, replaced by ast.Constant - self.add(repr(node.n)) + self._ast_constant(node) def _ast_pass(self, node): # pylint: disable=unused-argument """Add an AST Pass in output.""" @@ -287,7 +292,7 @@ class UnparsePython(object): def _ast_str(self, node): """Add an AST Str in output.""" # note: deprecated since Python 3.8, replaced by ast.Constant - self.add(repr(node.s)) + self._ast_constant(node) def _ast_subscript(self, node): """Add an AST Subscript in output."""