From 9f127cc420884adbd42f174ffa9973af01aa827b Mon Sep 17 00:00:00 2001 From: James Knight Date: Sat, 4 Sep 2021 21:35:19 -0400 Subject: [PATCH] utils/getdeveloperlib.py: explicitly set devs document encoding Explicitly indicate the file encoding to UTF-8 for the DEVELOPERS document. This prevents Unicode decoding errors when printing E-Mail entries with Unicode characters on systems using an alternative default encoding (e.g. 'CP1252'). This corrects the following observed error: $ ./utils/get-developers outgoing/* Traceback (most recent call last): File "utils\get-developers", line 105, in __main__() File "utils\get-developers", line 47, in __main__ devs = getdeveloperlib.parse_developers() File "...\buildroot\utils\getdeveloperlib.py", line 239, in parse_developers for line in f: File "...\Python\lib\encodings\cp1252.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 6659: character maps to Signed-off-by: James Knight Signed-off-by: Thomas Petazzoni --- utils/getdeveloperlib.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/getdeveloperlib.py b/utils/getdeveloperlib.py index b205817033..08abcfed54 100644 --- a/utils/getdeveloperlib.py +++ b/utils/getdeveloperlib.py @@ -1,4 +1,5 @@ from __future__ import print_function +from io import open import os import re import glob @@ -231,7 +232,8 @@ def parse_developers(): linen = 0 global unittests unittests = list_unittests() - with open(os.path.join(brpath, "DEVELOPERS"), "r") as f: + developers_fname = os.path.join(brpath, 'DEVELOPERS') + with open(developers_fname, mode='r', encoding='utf_8') as f: files = [] name = None for line in f: -- 2.30.2