diff options
author | Pedro Ferreira <Pedro.Silva.Ferreira@criticaltechworks.com> | 2025-03-07 10:33:51 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-03-09 20:10:06 +0000 |
commit | 3480f4dbe9f9f285c75c1e874ddf994400c08c16 (patch) | |
tree | 4a29eae3fd954edb839da6177edb54ae9b14234c /bitbake | |
parent | 19584fedb82fa6486f049a2645e4b2356a607fda (diff) | |
download | poky-3480f4dbe9f9f285c75c1e874ddf994400c08c16.tar.gz |
bitbake: codeparser: Skipping typing when inspecting Python modules
If a custom python module is added thru BBIMPORTS and it
uses typing(Any,Tuple,Union...), codeparser will fail because
inspect.py raises TypeError exception if the object is a
built-in module, class, or function.
(Bitbake rev: 0ecfd0b8540220633e71d24cd73cc5306863ae3c)
Signed-off-by: Pedro Silva Ferreira <Pedro.Silva.Ferreira@criticaltechworks.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/codeparser.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/bitbake/lib/bb/codeparser.py b/bitbake/lib/bb/codeparser.py index d249af326e..4bc6adbe45 100644 --- a/bitbake/lib/bb/codeparser.py +++ b/bitbake/lib/bb/codeparser.py | |||
@@ -72,12 +72,20 @@ def add_module_functions(fn, functions, namespace): | |||
72 | parser.parse_python(None, filename=fn, lineno=1, fixedhash=fixedhash+f) | 72 | parser.parse_python(None, filename=fn, lineno=1, fixedhash=fixedhash+f) |
73 | #bb.warn("Cached %s" % f) | 73 | #bb.warn("Cached %s" % f) |
74 | except KeyError: | 74 | except KeyError: |
75 | targetfn = inspect.getsourcefile(functions[f]) | 75 | try: |
76 | targetfn = inspect.getsourcefile(functions[f]) | ||
77 | except TypeError: | ||
78 | # Builtin | ||
79 | continue | ||
76 | if fn != targetfn: | 80 | if fn != targetfn: |
77 | # Skip references to other modules outside this file | 81 | # Skip references to other modules outside this file |
78 | #bb.warn("Skipping %s" % name) | 82 | #bb.warn("Skipping %s" % name) |
79 | continue | 83 | continue |
80 | lines, lineno = inspect.getsourcelines(functions[f]) | 84 | try: |
85 | lines, lineno = inspect.getsourcelines(functions[f]) | ||
86 | except TypeError: | ||
87 | # Builtin | ||
88 | continue | ||
81 | src = "".join(lines) | 89 | src = "".join(lines) |
82 | parser.parse_python(src, filename=fn, lineno=lineno, fixedhash=fixedhash+f) | 90 | parser.parse_python(src, filename=fn, lineno=lineno, fixedhash=fixedhash+f) |
83 | #bb.warn("Not cached %s" % f) | 91 | #bb.warn("Not cached %s" % f) |