[honister,3/4] oe/license: implement ast.NodeVisitor.visit_Constant

Message ID 20211210110814.112954-3-ross.burton@arm.com
State Accepted, archived
Commit c96241ac8e18f4ae87ec05b722a0bbfb017df578
Headers show
Series [honister,1/4] lib/pyinotify.py: Remove deprecated module asyncore | expand

Commit Message

Ross Burton Dec. 10, 2021, 11:08 a.m. UTC
From: Ross Burton <ross@burtonini.com>

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>
---
 meta/lib/oe/license.py | 6 ++++++
 1 file changed, 6 insertions(+)

Patch

diff --git a/meta/lib/oe/license.py b/meta/lib/oe/license.py
index 665d32ecbb1..b5d378a549b 100644
--- a/meta/lib/oe/license.py
+++ b/meta/lib/oe/license.py
@@ -74,6 +74,9 @@  class FlattenVisitor(LicenseVisitor):
     def visit_Str(self, node):
         self.licenses.append(node.s)
 
+    def visit_Constant(self, node):
+        self.licenses.append(node.value)
+
     def visit_BinOp(self, node):
         if isinstance(node.op, ast.BitOr):
             left = FlattenVisitor(self.choose_licenses)
@@ -227,6 +230,9 @@  class ListVisitor(LicenseVisitor):
     def visit_Str(self, node):
         self.licenses.add(node.s)
 
+    def visit_Constant(self, node):
+        self.licenses.add(node.value)
+
 def list_licenses(licensestr):
     """Simply get a list of all licenses mentioned in a license string.
        Binary operators are not applied or taken into account in any way"""