1
0
forked from VimPlug/jedi

added source_to_unicode method to deal with different encodings, davidhalter/jedi-vim#48

This commit is contained in:
David Halter
2012-12-19 20:35:24 +01:00
parent 15510a4c3b
commit 5e2e0a8f45
4 changed files with 49 additions and 11 deletions

View File

@@ -61,18 +61,14 @@ class Script(object):
:type col: int
:param source_path: The path in the os, the current module is in.
:type source_path: string or None
:param source_encoding: encoding for decoding `source`, when it
:param source_encoding: encoding for decoding `source`, if it
is not a `unicode` object.
:type source_encoding: string
"""
def __init__(self, source, line, column, source_path,
source_encoding='utf-8'):
source_encoding='utf-8'):
debug.reset_time()
try:
source = unicode(source, source_encoding, 'replace')
# Use 'replace' over 'ignore' to hold code structure.
except TypeError: # `source` is already a unicode object
pass
source = modules.source_to_unicode(source, source_encoding)
self.pos = line, column
self.module = modules.ModuleWithCursor(source_path, source=source,
position=self.pos)