1
0
forked from VimPlug/jedi

Compute default line/column/source_path in api.Script

This commit is contained in:
Takafumi Arakaki
2013-05-11 21:36:43 +02:00
parent 633f582184
commit 6af2a0677d

View File

@@ -54,8 +54,12 @@ class Script(object):
``unicode`` object (default ``'utf-8'``). ``unicode`` object (default ``'utf-8'``).
:type source_encoding: str :type source_encoding: str
""" """
def __init__(self, source, line, column, source_path, def __init__(self, source, line=None, column=None, source_path=None,
source_encoding='utf-8', fast=None): source_encoding='utf-8', fast=None):
lines = source.splitlines()
line = len(lines) if line is None else line
column = len(lines[-1]) if column is None else column
api_classes._clear_caches() api_classes._clear_caches()
debug.reset_time() debug.reset_time()
self.source = modules.source_to_unicode(source, source_encoding) self.source = modules.source_to_unicode(source, source_encoding)
@@ -537,9 +541,6 @@ class Interpreter(Script):
If `line` and `column` are None, they are assumed be at the end of If `line` and `column` are None, they are assumed be at the end of
`source`. `source`.
""" """
lines = source.splitlines()
line = len(lines) if line is None else line
column = len(lines[-1]) if column is None else column
super(Interpreter, self).__init__( super(Interpreter, self).__init__(
source, line, column, source_path, source_encoding, fast=False) source, line, column, source_path, source_encoding, fast=False)