From 6be592d2a7268ca394445539f6568d1c64fb0bc7 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Sun, 30 Jun 2024 23:12:50 +0100 Subject: [PATCH] bitbake: codeparser: Skip non-local functions for module dependencies If modules do something like "from glob import glob" then we end up checksumming the glob code. That leads to bugs as the code can change between different python versions for example, leading to checksum instability. We should ignore functions not from the current file as implemented by this change. (Bitbake rev: 1e6f862864539d6f6a0bea3e4479e0dd40ff3091) Signed-off-by: Richard Purdie --- bitbake/lib/bb/codeparser.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bitbake/lib/bb/codeparser.py b/bitbake/lib/bb/codeparser.py index 4c4758ecbe..b25a2133d2 100644 --- a/bitbake/lib/bb/codeparser.py +++ b/bitbake/lib/bb/codeparser.py @@ -72,6 +72,11 @@ def add_module_functions(fn, functions, namespace): parser.parse_python(None, filename=fn, lineno=1, fixedhash=fixedhash+f) #bb.warn("Cached %s" % f) except KeyError: + targetfn = inspect.getsourcefile(functions[f]) + if fn != targetfn: + # Skip references to other modules outside this file + #bb.warn("Skipping %s" % name) + continue lines, lineno = inspect.getsourcelines(functions[f]) src = "".join(lines) parser.parse_python(src, filename=fn, lineno=lineno, fixedhash=fixedhash+f)