scripts/spdxcheck.py: Strictly read license files in utf-8
PATCH v2 1/1 scripts/spdxcheck.py: Strictly read license files in utf-8
Commit bc41a7f36469 ("LICENSES: Add the CC-BY-4.0 license") unfortunately introduced LICENSES/dual/CC-BY-4.0 in UTF-8 Unicode text While python will barf at it with:
FAIL: 'ascii' codec can't decode byte 0xe2 in position 2109: ordinal not in range(128) Traceback (most recent call last):
File "scripts/spdxcheck.py", line 244, in <module>
spdx = read_spdxdata(repo)
File "scripts/spdxcheck.py", line 47, in read_spdxdata
for l in open(el.path).readlines():
File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 2109: ordinal not in range(128)
While it is indeed debatable if 'Licensor.' used in the license file needs unicode quotes, instead, force spdxcheck to read utf-8.
---
Changes since V1:
* Commit message update to drop "Let's" "Let us".
* Picked up Thomas' Reviewed-by
V1: https://lore.kernel.org/linux-spdx/[email protected]/
scripts/spdxcheck.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/spdxcheck.py +1 -1
@@ -44,7 +44,7 @@ def read_spdxdata(repo): continue exception = None - for l in open(el.path).readlines(): + for l in open(el.path, encoding="utf-8").readlines(): if l.startswith('Valid-License-Identifier:'): lid = l.split(':')[1].strip().upper() if lid in spdx.licenses:
Signature · 1 line
2.32.0
Jonathan Corbet
AppliedQuoted 14 lines · Nishanth Menon
Commit
bc41a7f36469("LICENSES: Add the CC-BY-4.0 license") unfortunately introducedLICENSES/dual/CC-BY-4.0in UTF-8 Unicode text While python will barf at it with:FAIL: 'ascii' codec can't decode byte
0xe2in position 2109: ordinal not in range(128) Traceback (most recent call last):
File "scripts/spdxcheck.py", line 244, in <module>
spdx =read_spdxdata(repo)
File "scripts/spdxcheck.py", line 47, inread_spdxdata
for l in open(el.path).readlines():
File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
returncodecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte0xe2in position 2109: ordinal not in range(128)
Quoted 6 lines
While it is indeed debatable if 'Licensor.' used in the license file needs unicode quotes, instead, force spdxcheck to read utf-8.
Reported-by Rahul T R <[email protected]>Signed-off-by Nishanth Menon <[email protected]>Reviewed-by Thomas Gleixner <[email protected]>
I've applied this, thanks.
jon