qemu-e2k/scripts
Philippe Mathieu-Daudé 4cacecaaa2 decodetree: Open files with encoding='utf-8'
When decodetree.py was added in commit 568ae7efae, QEMU was
using Python 2 which happily reads UTF-8 files in text mode.
Python 3 requires either UTF-8 locale or an explicit encoding
passed to open(). Now that Python 3 is required, explicit
UTF-8 encoding for decodetree source files.

To avoid further problems with the user locale, also explicit
UTF-8 encoding for the generated C files.

Explicit both input/output are plain text by using the 't' mode.

This fixes:

  $ /usr/bin/python3 scripts/decodetree.py test.decode
  Traceback (most recent call last):
    File "scripts/decodetree.py", line 1397, in <module>
      main()
    File "scripts/decodetree.py", line 1308, in main
      parse_file(f, toppat)
    File "scripts/decodetree.py", line 994, in parse_file
      for line in f:
    File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
      return codecs.ascii_decode(input, self.errors)[0]
  UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 80:
  ordinal not in range(128)

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Suggested-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20210110000240.761122-1-f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2021-01-13 08:39:08 -10:00
..
ci
coccinelle
codeconverter
coverity-scan
kvm
modules
oss-fuzz
performance
qapi
qemu-guest-agent
qemugdb
qmp
simplebench
tracetool
travis
analyse-9p-simpletrace.py
analyse-locks-simpletrace.py
analyze-inclusions
analyze-migration.py
archive-source.sh
block-coroutine-wrapper.py
check_sparse.py
checkpatch.pl
clean-header-guards.pl
clean-includes
cleanup-trace-events.pl
cocci-macro-file.h
coverity-model.c
decodetree.py
device-crash-test
disas-objdump.pl
dump-guest-memory.py
extract-vsssdk-headers
feature_to_c.sh
fix-multiline-comments.sh
gensyscalls.sh
get_maintainer.pl
git-submodule.sh
git.orderfile
hxtool
hxtool-conv.pl
kernel-doc
make-release
meson.build
minikconf.py
mtest2make.py
nsis.py
qapi-gen.py
qemu-binfmt-conf.sh
qemu-gdb.py
qemu-trace-stap
qemu-version.sh
refresh-pxe-roms.sh
render_block_graph.py
replay-dump.py
shaderinclude.pl
show-fixed-bugs.sh
signrom.py
simpletrace.py
switch-timer-api
tap-driver.pl
tap-merge.pl
test-driver.py
tracetool.py
u2f-setup-gen.py
undefsym.py
update-linux-headers.sh
update-mips-syscall-args.sh
update-syscalltbl.sh
vmstate-static-checker.py