Message250175
| Author |
yves |
| Recipients |
ezio.melotti, vstinner, yves |
| Date |
2015年09月08日.09:46:01 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1441705562.15.0.558425697033.issue25028@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I am trying to read json containing a UTF-8 string from a file. It works when running it from a shell with LANG=en_GB.utf8 set, but fails from the empty environment.
> python3 --version
Python 3.4.0
> cat test.json
{ "test": "Ümläute" }
> env -u LANG python3 -c 'import json; json.load(open("test.json"))'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.4/json/__init__.py", line 265, in load
return loads(fp.read(),
File "/usr/lib/python3.4/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 11: ordinal not in range(128)
> > env LANG=en_GB.UTF-8 python3 -c 'import json; print(json.load(open("test.json")))'
{'test': 'Ümläute'} |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2015年09月08日 09:46:02 | yves | set | recipients:
+ yves, vstinner, ezio.melotti |
| 2015年09月08日 09:46:02 | yves | set | messageid: <1441705562.15.0.558425697033.issue25028@psf.upfronthosting.co.za> |
| 2015年09月08日 09:46:02 | yves | link | issue25028 messages |
| 2015年09月08日 09:46:01 | yves | create |
|