1
0
forked from VimPlug/jedi

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
2014-04-23 16:25:12 +02:00
parent 67f49da15c
commit 9ed0dc4861
4 changed files with 24 additions and 8 deletions

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