diff options
author | Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> | 2022-04-14 13:06:35 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-04-19 14:14:12 +0100 |
commit | f72889eb00fbb6be645f6c67012c2d81b7a06b64 (patch) | |
tree | db95c9c2155ff94cba6e67174fbde521a5397416 /scripts/lib/recipetool | |
parent | e4b2dd51a41b9f2ee1ed18c57b0668bdbbfdccc6 (diff) | |
download | poky-f72889eb00fbb6be645f6c67012c2d81b7a06b64.tar.gz |
recipetool: Do not use mutable default arguments in Python
Remove mutable default arguments in Python because they can lead to all
sorts of nasty and horrible bugs.
https://florimond.dev/en/posts/2018/08/python-mutable-defaults-are-the-source-of-all-evil/
Revert `recipetool: Change default paramter fallback_licenses of
function split_pkg_licenses from None to []` and instead check
fallback_licenses before use.
(From OE-Core rev: 99dee60b8db557f54783bf0f61098587badc683c)
Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/recipetool')
-rw-r--r-- | scripts/lib/recipetool/create.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py index 220465ed2f..824ac6350d 100644 --- a/scripts/lib/recipetool/create.py +++ b/scripts/lib/recipetool/create.py | |||
@@ -1235,7 +1235,7 @@ def guess_license(srctree, d): | |||
1235 | 1235 | ||
1236 | return licenses | 1236 | return licenses |
1237 | 1237 | ||
1238 | def split_pkg_licenses(licvalues, packages, outlines, fallback_licenses=[], pn='${PN}'): | 1238 | def split_pkg_licenses(licvalues, packages, outlines, fallback_licenses=None, pn='${PN}'): |
1239 | """ | 1239 | """ |
1240 | Given a list of (license, path, md5sum) as returned by guess_license(), | 1240 | Given a list of (license, path, md5sum) as returned by guess_license(), |
1241 | a dict of package name to path mappings, write out a set of | 1241 | a dict of package name to path mappings, write out a set of |
@@ -1258,7 +1258,7 @@ def split_pkg_licenses(licvalues, packages, outlines, fallback_licenses=[], pn=' | |||
1258 | for pkgname in packages: | 1258 | for pkgname in packages: |
1259 | # Assume AND operator between license files | 1259 | # Assume AND operator between license files |
1260 | license = ' & '.join(list(set(pkglicenses.get(pkgname, ['Unknown'])))) or 'Unknown' | 1260 | license = ' & '.join(list(set(pkglicenses.get(pkgname, ['Unknown'])))) or 'Unknown' |
1261 | if license == 'Unknown' and pkgname in fallback_licenses: | 1261 | if license == 'Unknown' and fallback_licenses and pkgname in fallback_licenses: |
1262 | license = fallback_licenses[pkgname] | 1262 | license = fallback_licenses[pkgname] |
1263 | licenses = tidy_licenses(license) | 1263 | licenses = tidy_licenses(license) |
1264 | license = ' & '.join(licenses) | 1264 | license = ' & '.join(licenses) |