forked from VimPlug/jedi
Merge branch 'dev' of github.com:davidhalter/jedi into dev
This commit is contained in:
@@ -60,6 +60,15 @@ try:
|
||||
except NameError:
|
||||
unicode = str
|
||||
|
||||
if is_py3k:
|
||||
utf8 = lambda s: s
|
||||
else:
|
||||
utf8 = lambda s: s.decode('utf-8')
|
||||
|
||||
utf8.__doc__ = """
|
||||
Decode a raw string into unicode object. Do nothing in Python 3.
|
||||
"""
|
||||
|
||||
# exec function
|
||||
if is_py3k:
|
||||
def exec_function(source, global_map):
|
||||
|
||||
12
jedi/api.py
12
jedi/api.py
@@ -60,9 +60,17 @@ 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
|
||||
is not a `unicode` object.
|
||||
:type source_encoding: string
|
||||
"""
|
||||
def __init__(self, source, line, column, source_path):
|
||||
source = unicode(source)
|
||||
def __init__(self, source, line, column, source_path,
|
||||
source_encoding='utf-8'):
|
||||
try:
|
||||
source = unicode(source, source_encoding, 'replace')
|
||||
# Use 'replace' over 'ignore' to hold code structure.
|
||||
except TypeError: # `source` is already a unicode object
|
||||
pass
|
||||
self.pos = line, column
|
||||
self.module = modules.ModuleWithCursor(source_path, source=source,
|
||||
position=self.pos)
|
||||
|
||||
Reference in New Issue
Block a user