Skip to contentSkip to conversation

bitbake: query: Fix using "removeprefix" string method

PATCH New Joshua Watt 1 participant 1 message Feb 20, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bitbake: query: Fix using "removeprefix" string method

From: Joerg Schmidt <[email protected]>

The minimum Python version required for Yocto 5.0 is 3.8 which causes failure in poky/bitbake/lib/bblayers/query.py when listing layers by using command "bitbake-layers show-recipes -f --bare --mc MC" for the given multiconfig MC.
The reason for that failure is the use of "removeprefix" string method which got introduced in Python 3.9.
This patch replaces the "removeprefix" method with an equivalent solution supported by Python 3.8.

---
 bitbake/lib/bblayers/query.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
bitbake/lib/bblayers/query.py +2 -1
index eb7cb465b4e..9b2e081cfd4 100644
@@ -145,7 +145,8 @@ skipped recipes will also be listed, with a " (skipped)" suffix.
         skiplist = list(self.tinfoil.cooker.skiplist_by_mc[mc].keys())
 
         if mc:
-            skiplist = [s.removeprefix(f'mc:{mc}:') for s in skiplist]
+            mcspec = f'mc:{mc}:'
+            skiplist = [s[len(mcspec):] if s.startswith(mcspec) else s for s in skiplist]
 
         for fn in skiplist:
             recipe_parts = os.path.splitext(os.path.basename(fn))[0].split('_')
Signature · 1 line
2.47.1