[2.0][kirkstone][PATCH 0/3] pick python 3.12 fixes
These 3 patches are fast forward cherry picked from master branch. They fix some oe-selftests on Fedora 39 with Python 3.12.
git cherry-pick 5419a8473d6d4cd1d01537de68ad8d72cf5be0b2 git cherry-pick de8ba2770d9a1a94af3d084f9540da7e2fae6022 git cherry-pick a5f1bc69ef2e456bd163303a07cfb73825b01576
More fixes are needed and will be sent to oe-core.
Adrian Freihofer (1):
bitbake/lib/bs4/tests/test_tree.py: python 3.12 regex
Alexander Kanavin (1):
bitbake/codeparser.py: address ast module deprecations in py 3.12
Chris Laplante (1):
codeparser: replace deprecated ast.Str and 's'
lib/bb/codeparser.py | 24 ++++++++++++------------ lib/bs4/tests/test_tree.py | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-)
Signature · 1 line
2.43.1
[2.0][kirkstone][PATCH 1/3] codeparser: replace deprecated ast.Str and 's'
From: Chris Laplante <[email protected]>
These have been deprecated since 3.8
--- lib/bb/codeparser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/bb/codeparser.py +2 -2
@@ -225,8 +225,8 @@ class PythonParser(): def visit_Call(self, node): name = self.called_node_name(node.func) if name and (name.endswith(self.getvars) or name.endswith(self.getvarflags) or name in self.containsfuncs or name in self.containsanyfuncs): - if isinstance(node.args[0], ast.Str): - varname = node.args[0].s + if isinstance(node.args[0], ast.Constant) and isinstance(node.args[0].value, str): + varname = node.args[0].value if name in self.containsfuncs and isinstance(node.args[1], ast.Str): if varname not in self.contains: self.contains[varname] = set()
Signature · 1 line
2.43.1
[2.0][kirkstone][PATCH 2/3] bitbake/codeparser.py: address ast module deprecations in py 3.12
In reply to Adrian FreihoferFrom: Alexander Kanavin <[email protected]>
Specifically:/srv/work/alex/poky/bitbake/lib/bb/codeparser.py:279: DeprecationWarning: ast.Str is deprecated and will be removed in Python 3.14; use ast.Constant instead
if isinstance(node.args[0], ast.Str):/srv/work/alex/poky/bitbake/lib/bb/codeparser.py:280: DeprecationWarning: Attribute s is deprecated and will be removed in Python 3.14; use value instead
value = node.args[0].s
--- lib/bb/codeparser.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
lib/bb/codeparser.py +10 -10
@@ -227,17 +227,17 @@ class PythonParser(): if name and (name.endswith(self.getvars) or name.endswith(self.getvarflags) or name in self.containsfuncs or name in self.containsanyfuncs): if isinstance(node.args[0], ast.Constant) and isinstance(node.args[0].value, str): varname = node.args[0].value - if name in self.containsfuncs and isinstance(node.args[1], ast.Str): + if name in self.containsfuncs and isinstance(node.args[1], ast.Constant): if varname not in self.contains: self.contains[varname] = set() - self.contains[varname].add(node.args[1].s) - elif name in self.containsanyfuncs and isinstance(node.args[1], ast.Str): + self.contains[varname].add(node.args[1].value) + elif name in self.containsanyfuncs and isinstance(node.args[1], ast.Constant): if varname not in self.contains: self.contains[varname] = set() - self.contains[varname].update(node.args[1].s.split()) + self.contains[varname].update(node.args[1].value.split()) elif name.endswith(self.getvarflags): - if isinstance(node.args[1], ast.Str): - self.references.add('%s[%s]' % (varname, node.args[1].s)) + if isinstance(node.args[1], ast.Constant): + self.references.add('%s[%s]' % (varname, node.args[1].value)) else: self.warn(node.func, node.args[1]) else:
@@ -245,8 +245,8 @@ class PythonParser(): else: self.warn(node.func, node.args[0]) elif name and name.endswith(".expand"): - if isinstance(node.args[0], ast.Str): - value = node.args[0].s + if isinstance(node.args[0], ast.Constant): + value = node.args[0].value d = bb.data.init() parser = d.expandWithRefs(value, self.name) self.references |= parser.references
@@ -256,8 +256,8 @@ class PythonParser(): self.contains[varname] = set() self.contains[varname] |= parser.contains[varname] elif name in self.execfuncs: - if isinstance(node.args[0], ast.Str): - self.var_execs.add(node.args[0].s) + if isinstance(node.args[0], ast.Constant): + self.var_execs.add(node.args[0].value) else: self.warn(node.func, node.args[0]) elif name and isinstance(node.func, (ast.Name, ast.Attribute)):
Signature · 1 line
2.43.1
[2.0][kirkstone][PATCH 3/3] bitbake/lib/bs4/tests/test_tree.py: python 3.12 regex
In reply to Adrian FreihoferFrom: Adrian Freihofer <[email protected]>
Python 3 interprets string literals as Unicode strings, and therefore \s is treated as an escaped Unicode character which is not correct. Declaring the RegEx pattern as a raw string instead of unicode is required for Python 3.
--- lib/bs4/tests/test_tree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bs4/tests/test_tree.py +1 -1
@@ -585,7 +585,7 @@ class SiblingTest(TreeTest): </html>''' # All that whitespace looks good but makes the tests more # difficult. Get rid of it. - markup = re.compile("\n\s*").sub("", markup) + markup = re.compile(r"\n\s*").sub("", markup) self.tree = self.soup(markup)
Signature · 1 line
2.43.1