homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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:02yvessetrecipients: + yves, vstinner, ezio.melotti
2015年09月08日 09:46:02yvessetmessageid: <1441705562.15.0.558425697033.issue25028@psf.upfronthosting.co.za>
2015年09月08日 09:46:02yveslinkissue25028 messages
2015年09月08日 09:46:01yvescreate

AltStyle によって変換されたページ (->オリジナル) /