Skip to content

Commit 40751c6

Browse files
nmenonJonathan Corbet
authored andcommitted
scripts/spdxcheck.py: Strictly read license files in utf-8
Commit bc41a7f ("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. Reported-by: Rahul T R <[email protected]> Signed-off-by: Nishanth Menon <[email protected]> Reviewed-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Corbet <[email protected]>
1 parent e73f0f0 commit 40751c6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

scripts/spdxcheck.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def read_spdxdata(repo):
4444
continue
4545

4646
exception = None
47-
for l in open(el.path).readlines():
47+
for l in open(el.path, encoding="utf-8").readlines():
4848
if l.startswith('Valid-License-Identifier:'):
4949
lid = l.split(':')[1].strip().upper()
5050
if lid in spdx.licenses:

0 commit comments

Comments
 (0)