diff mbox series

[scarthgap,2.8,2/2] codeparser: Skip non-local functions for module dependencies

Message ID 11d83170922a2c6b9db1f6e8c23e533526984b2c.1721310419.git.steve@sakoman.com
State New
Headers show
Series [scarthgap,2.8,1/2] codeparser/data: Ensure module function contents changing is accounted for | expand

Commit Message

Steve Sakoman July 18, 2024, 1:48 p.m. UTC
From: Richard Purdie <richard.purdie@linuxfoundation.org>

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.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 1e6f862864539d6f6a0bea3e4479e0dd40ff3091)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
---
 lib/bb/codeparser.py | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/lib/bb/codeparser.py b/lib/bb/codeparser.py
index 0b2890cf8..1001ca190 100644
--- a/lib/bb/codeparser.py
+++ b/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)