From: Martin Pitt Date: Thu, 24 Nov 2016 09:38:01 +0000 (+0100) Subject: hwdb/parse_hwdb.py: open files with UTF-8 mode X-Git-Tag: v233~391^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=115a10c58d343d00b73bd9442f7ce6c294debad8;p=thirdparty%2Fsystemd.git hwdb/parse_hwdb.py: open files with UTF-8 mode pyparsing uses the system locale by default, which in the case of 'C' (in lots of build environment) will fail with a UnicodeDecodeError. Explicitly open it with UTF-8 encoding to guard against this. --- diff --git a/hwdb/parse_hwdb.py b/hwdb/parse_hwdb.py index 5d4c5ea64df..556b8591916 100755 --- a/hwdb/parse_hwdb.py +++ b/hwdb/parse_hwdb.py @@ -133,7 +133,8 @@ def convert_properties(group): def parse(fname): grammar = hwdb_grammar() try: - parsed = grammar.parseFile(fname) + with open(fname, 'r', encoding='UTF-8') as f: + parsed = grammar.parseFile(f) except ParseBaseException as e: error('Cannot parse {}: {}', fname, e) return []