X Tutup
Skip to content

Commit 8ff8678

Browse files
committed
Catch jedi errors
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
1 parent a5e541b commit 8ff8678

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

bpython/autocomplete.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ def matches(self, cursor_offset, line, **kwargs):
347347
return None
348348
else:
349349
class JediCompletion(BaseCompletionType):
350+
350351
def matches(self, cursor_offset, line, **kwargs):
351352
if 'history' not in kwargs:
352353
return None
@@ -355,9 +356,13 @@ def matches(self, cursor_offset, line, **kwargs):
355356
if not lineparts.current_word(cursor_offset, line):
356357
return None
357358
history = '\n'.join(history) + '\n' + line
358-
script = jedi.Script(history, len(history.splitlines()),
359-
cursor_offset, 'fake.py')
360-
completions = script.completions()
359+
try:
360+
script = jedi.Script(history, len(history.splitlines()),
361+
cursor_offset, 'fake.py')
362+
completions = script.completions()
363+
except jedi.NotFoundError:
364+
self._orig_start = None
365+
return None
361366
if completions:
362367
diff = len(completions[0].name) - len(completions[0].complete)
363368
self._orig_start = cursor_offset - diff
@@ -381,6 +386,7 @@ def locate(self, cursor_offset, line):
381386
end = cursor_offset
382387
return start, end, line[start:end]
383388

389+
384390
class MultilineJediCompletion(JediCompletion):
385391
def matches(self, cursor_offset, line, **kwargs):
386392
if 'current_block' not in kwargs or 'history' not in kwargs:

0 commit comments

Comments
 (0)
X Tutup