From 16aa8a74130b3d175c8c547a3c8ba38d5526cce1 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Fri, 11 Jan 2019 16:07:41 +0100 Subject: [PATCH] Use io.open(encoding=utf8) in extract_symbols/sections.py (fixes #33360) --- lasso/extract_sections.py | 6 +++--- lasso/extract_symbols.py | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lasso/extract_sections.py b/lasso/extract_sections.py index 8a1f675f..ac9a4ae9 100644 --- a/lasso/extract_sections.py +++ b/lasso/extract_sections.py @@ -1,6 +1,6 @@ #! /usr/bin/env python -import glob +import io import re import sys import os @@ -24,8 +24,8 @@ for root, dirs, files in os.walk(srcdir): prefixes.append(os.path.splitext(file)[0]) for prefix in prefixes: try: - header = open(os.path.join(root, prefix + '.h')).read() - implementation = open(os.path.join(root, prefix + '.c')).read() + header = io.open(os.path.join(root, prefix + '.h'), encoding='utf-8').read() + implementation = io.open(os.path.join(root, prefix + '.c'), encoding='utf-8').read() exported_functions = re.findall('LASSO_EXPORT.*(lasso_\w*)', header) normal_functions = sorted ([ x for x in exported_functions if not x.endswith('get_type') ]) get_type = [ x for x in exported_functions if x.endswith('get_type') ][0] diff --git a/lasso/extract_symbols.py b/lasso/extract_symbols.py index 6b1f2975..b06b7a57 100644 --- a/lasso/extract_symbols.py +++ b/lasso/extract_symbols.py @@ -1,5 +1,6 @@ #! /usr/bin/env python +import io import glob import re import sys @@ -22,7 +23,7 @@ for header_file in glob.glob('%s/*/*.h' % srcdir) + glob.glob('%s/*.h' % srcdir) glob.glob('%s/*/*/*.h' % srcdir): if ('/id-wsf/' in header_file or '/id-wsf-2.0' in header_file) and not enable_wsf: continue - symbols.extend(regex.findall(open(header_file).read().replace('\\\n', ''))) + symbols.extend(regex.findall(io.open(header_file, encoding='utf-8').read().replace('\\\n', ''))) wsf = ['lasso_disco_', 'lasso_dst_', 'lasso_is_', 'lasso_profile_service_', 'lasso_discovery', 'lasso_wsf', 'lasso_interaction_', 'lasso_utility_',