diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2009-01-18 20:15:42 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2009-01-18 20:15:42 (GMT) |
commit | 975a079794cf1672c2b917f946da25966f75c6b6 (patch) | |
tree | 1e5e536be53abddc607e7fdaf87df0b1613a1c0f /Lib/idlelib/IOBinding.py | |
parent | 1cbb17a818a70aacd6cbecd3411a2f91a08b7826 (diff) | |
download | cpython-975a079794cf1672c2b917f946da25966f75c6b6.zip cpython-975a079794cf1672c2b917f946da25966f75c6b6.tar.gz cpython-975a079794cf1672c2b917f946da25966f75c6b6.tar.bz2 |
Issue #4008: Fix problems with non-ASCII source files.
Diffstat (limited to 'Lib/idlelib/IOBinding.py')
-rw-r--r-- | Lib/idlelib/IOBinding.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/idlelib/IOBinding.py b/Lib/idlelib/IOBinding.py index 516cb75..71c0163 100644 --- a/Lib/idlelib/IOBinding.py +++ b/Lib/idlelib/IOBinding.py @@ -74,10 +74,11 @@ def coding_spec(data): Raise a LookupError if the encoding is declared but unknown. """ if isinstance(data, bytes): - try: - lines = data.decode('utf-8') - except UnicodeDecodeError: - return None + # This encoding might be wrong. However, the coding + # spec must be ASCII-only, so any non-ASCII characters + # around here will be ignored. Decoding to Latin-1 should + # never fail (except for memory outage) + lines = data.decode('iso-8859-1') else: lines = data # consider only the first two lines |