Closed akosthekiss closed 5 years ago
Issue was triggered when running tox on the following system setup:
Interestingly, tox runs fine on a Ubuntu 18.04.1 LTS system. Some digging has revealed that on macOS (and only on macOS), locale.getpreferredencoding()
got set to US-ASCII
from the otherwise default UTF-8
when inside tox. This tox behaviour is quite strange, but it signals an issue nonetheless.
Notes:
open
builtin for the sake of simplicity. API users will solve the correct opening of the files on their own, most probably.errors='ignore'
to the io.open()
calls. Sometimes it is used to make file reading fool proof. Sometimes it is considered a bad practice that hides real problems.open
s touched in main.py
and test_spec.py
don't really affect the API user of the package, they only enforce utf-8 encoding on the command line user and on the testing framework. However, the open
changed in renderer.py
in _get_partial
has an effect on the API user as -- at least for now -- there is no way for them to specify a different encoding, should it be needed for their partial files. But hard-coded utf-8 encoding/decoding of strings is used throughout the code anyway.
```
Traceback (most recent call last):
File "/Users/akiss/devel/gpufuzz/chevron/test_spec.py", line 54, in
PR rebased to latest master to make Travis CI go green.
The default
open(..., 'r')
may lead to errors when utf-8 encoded files are read on a platform with non-utf-8 default locale / preferred encoding. Theio
package allows to specifyencoding
foropen
in a Python 2 & 3-compatible way.