You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2019/03/29 00:56:12 UTC
[GitHub] [incubator-superset] john-bodley opened a new pull request #7166:
[encoding] Adding explicit encoding when opening file contain utf-8
characters
john-bodley opened a new pull request #7166: [encoding] Adding explicit encoding when opening file contain utf-8 characters
URL: https://github.com/apache/incubator-superset/pull/7166
We came across a situation where `open(...)` threw a `UnicodeDecodeError` as the `backendSync.json` file now contains non ascii characters [here](https://github.com/apache/incubator-superset/blob/master/superset/assets/backendSync.json#L1189-L1190) (which was introduced in v0.31), i.e.,
```
File "/usr/local/lib/python3.6/dist-packages/superset/__init__.py", line 48, in <module>
frontend_config = json.load(f)
File "/usr/lib/python3.6/json/__init__.py", line 296, in load
return loads(fp.read(),
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 0xc2 in position 23166: ordinal not in range(128)
```
According to the [documentation] when using `open(...)` without an explicit encoding the encoding is [determined](http://python-notes.curiousefficiency.org/en/latest/python3/text_file_processing.html#files-in-a-typical-platform-specific-encoding) from the OS. It seems prudent however to explicitly define the encoding when the encoding is [known](http://python-notes.curiousefficiency.org/en/latest/python3/text_file_processing.html#files-in-a-consistent-known-encoding).
Note there are other examples in the code base where the encoding is explicitly defined and thus this doesn't seem to be an anti-pattern.
to: @graceguo-supercat @michellethomas @mistercrunch
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org