work around failure of test 185 in single-byte locales

The Windows CI runs with codepage 1252, which is basically ISO-8859-1 and does not
have a mapping for character U+0151 (ő).  It is currently passing because of a
happy accident, as the generator command line is emitted in UTF-8 anyway
(starting at commit 6089631a, "Open build files with utf-8", 2018-04-17, which
however lacks documentation or history) and file.py treats it as two
single-byte characters.

When going through meson_exe, however, Windows passes a genuine Unicode
character via CreateProcessW and file.py fails to decode it, so we need to
pass errors='replace' when opening the output file.

On Windows, the test is then fixed.  On POSIX systems it is _still_ passing as
a happy accident because (according to the current locale) the output file
contains two single-byte characters rather than the single Unicode character
"ő"; in fact, if one modifies the ninja backend to use force_serialize=True,
meson_exe fails to build the command line for file.py and stops with a
UnicodeEncodeError.
pull/5644/head
Paolo Bonzini 6 years ago
parent d7a682fded
commit 28c93ce4af
  1. 2
      test cases/common/185 escape and unicode/file.py

@ -6,5 +6,5 @@ import os
with open(sys.argv[1]) as fh:
content = fh.read().replace("{NAME}", sys.argv[2])
with open(os.path.join(sys.argv[3]), 'w') as fh:
with open(os.path.join(sys.argv[3]), 'w', errors='replace') as fh:
fh.write(content)

Loading…
Cancel
Save