Always load source files in binary mode.

Source files can be in any coding system, provided Python can
read a coding: line at the beginning of the file. So source files
should be loaded in binary format and decoded according to that
line, not assumed to be in the default coding system.

Fixes #398.
This commit is contained in:
Jorgen Schaefer committed 2014-04-24 11:10:59 +02:00
1 parent 67f49da15c
commit 9ed0dc4861
4 files changed
+24 -8

No files matched your search

+1 -3
View File
@@ -31,9 +31,7 @@ def find_module_py33(string, path=None):
module_file = None
else:
module_path = loader.get_filename(string)
module_ext = os.path.splitext(module_path)[1]
mode = 'rb' if module_ext in ['.pyc', '.so', '.pyd'] else 'r'
module_file = open(module_path, mode)
module_file = open(module_path, 'rb')
except AttributeError:
# ExtensionLoader has not attribute get_filename, instead it has a
# path attribute that we can use to retrieve the module path