Use io.open(encoding=utf8) in extract_symbols/sections.py (fixes #33360)

This commit is contained in:
Benjamin Dauvergne 2019-01-11 16:07:41 +01:00
parent 151ad17e04
commit 16aa8a7413
2 changed files with 5 additions and 4 deletions

View File

@ -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]

View File

@ -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_',