mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
fix unicode problems in sith.py
This commit is contained in:
6
sith.py
6
sith.py
@@ -111,9 +111,7 @@ class TestCase(object):
|
|||||||
def run(self, debugger, record=None, print_result=False):
|
def run(self, debugger, record=None, print_result=False):
|
||||||
try:
|
try:
|
||||||
with open(self.path) as f:
|
with open(self.path) as f:
|
||||||
self.file = f.read()
|
self.script = jedi.Script(f.read(), self.line, self.column, self.path)
|
||||||
self.script = jedi.Script(self.file, self.line, self.column,
|
|
||||||
self.path)
|
|
||||||
self.completions = getattr(self.script, self.operation)()
|
self.completions = getattr(self.script, self.operation)()
|
||||||
if print_result:
|
if print_result:
|
||||||
self.show_location(self.line, self.column)
|
self.show_location(self.line, self.column)
|
||||||
@@ -138,7 +136,7 @@ class TestCase(object):
|
|||||||
def show_location(self, lineno, column, show=3):
|
def show_location(self, lineno, column, show=3):
|
||||||
# Three lines ought to be enough
|
# Three lines ought to be enough
|
||||||
lower = lineno - show if lineno - show > 0 else 0
|
lower = lineno - show if lineno - show > 0 else 0
|
||||||
for i, line in enumerate(self.file.split('\n')[lower:lineno]):
|
for i, line in enumerate(self.script.source.split('\n')[lower:lineno]):
|
||||||
print(lower + i + 1, line)
|
print(lower + i + 1, line)
|
||||||
print(' ' * (column + len(str(lineno))), '^')
|
print(' ' * (column + len(str(lineno))), '^')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user