You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem: test files, result files contain UTF-8 symbols, which are
out of ASCII range. Just `open(file, 'r').read()` without the
encoding='utf-8' argument fails to decode them, when the default
encoding for file text streams is not 'utf-8'. We meet this situation on
Python 3.6.8 (provided by CentOS 7 and CentOS 8), when the POSIX locale
is set (`LC_ALL=C`).
The solution is described in the code comment: replace `open()` built-in
function and always set `encoding='utf-8'`. That's hacky way, but it
looks better than change every `open()` call across the code and don't
forget to do that in all future code (and keep Python 2 compatibility in
the mind). But maybe we'll revisit the approach later.
There is another way to hack the `open()` behaviour that works for me on
Python 3.6.8:
| import _bootlocale
| _bootlocale.getpreferredencoding = (lambda *args: 'utf8')
However it leans on Python internals and looks less reliable than the
implemented one.
Part of #20
0 commit comments