minikconf: explicitly set encoding to UTF-8

QEMU currently only has ASCII Kconfig files but Linux actually uses
UTF-8. Explicitly specify the encoding and that we're doing text file
I/O.

It's unclear whether or not QEMU will ever need Unicode in its Kconfig
files. If we start using the help text then it will become an issue
sooner or later. Make this change now for consistency with Linux
Kconfig.

Reported-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20200521153616.307100-1-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Stefan Hajnoczi 2020-05-21 16:36:16 +01:00
parent 171199f56f
commit ddd633e525

View file

@ -402,7 +402,7 @@ class KconfigParser:
if incl_abs_fname in self.data.previously_included: if incl_abs_fname in self.data.previously_included:
return return
try: try:
fp = open(incl_abs_fname, 'r') fp = open(incl_abs_fname, 'rt', encoding='utf-8')
except IOError as e: except IOError as e:
raise KconfigParserError(self, raise KconfigParserError(self,
'%s: %s' % (e.strerror, include)) '%s: %s' % (e.strerror, include))
@ -696,7 +696,7 @@ if __name__ == '__main__':
parser.do_assignment(name, value == 'y') parser.do_assignment(name, value == 'y')
external_vars.add(name[7:]) external_vars.add(name[7:])
else: else:
fp = open(arg, 'r') fp = open(arg, 'rt', encoding='utf-8')
parser.parse_file(fp) parser.parse_file(fp)
fp.close() fp.close()
@ -705,7 +705,7 @@ if __name__ == '__main__':
if key not in external_vars and config[key]: if key not in external_vars and config[key]:
print ('CONFIG_%s=y' % key) print ('CONFIG_%s=y' % key)
deps = open(argv[2], 'w') deps = open(argv[2], 'wt', encoding='utf-8')
for fname in data.previously_included: for fname in data.previously_included:
print ('%s: %s' % (argv[1], fname), file=deps) print ('%s: %s' % (argv[1], fname), file=deps)
deps.close() deps.close()