diff options
author | Ross Burton <ross@burtonini.com> | 2021-10-13 16:10:17 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-10-14 22:32:52 +0100 |
commit | 4edd5767fc6d699f5262862b763b6a99ad1f1bbf (patch) | |
tree | d868bd245e514fb5b0f6a05acda9d402ec3bb32c | |
parent | 4fa25714916e84f99ecd22cb76cb5adada01e5e8 (diff) | |
download | bitbake-4edd5767fc6d699f5262862b763b6a99ad1f1bbf.tar.gz |
codegen: implement ast.NodeVisitor.visit_Constant
Since Python 3.8 visit_Num(), visit_Str() and so on are all deprecated
and replaced with visit_Constant. We can't yet remove the deprecated
functions until we require 3.8, but we can implement visit_Constant to
silence the deprecation warnings.
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | lib/codegen.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/codegen.py b/lib/codegen.py index 62a6748c4..6955a7ada 100644 --- a/lib/codegen.py +++ b/lib/codegen.py @@ -401,6 +401,12 @@ class SourceGenerator(NodeVisitor): def visit_Num(self, node): self.write(repr(node.n)) + def visit_Constant(self, node): + # Python 3.8 deprecated visit_Num(), visit_Str(), visit_Bytes(), + # visit_NameConstant() and visit_Ellipsis(). They can be removed once we + # require 3.8+. + self.write(repr(node.value)) + def visit_Tuple(self, node): self.write('(') idx = -1 |