More stable exception handling in the completer.

This commit is contained in:
a 2020-10-07 18:28:11 +03:00
parent ff4b6c1bc6
commit eb12f95976
2 changed files with 31 additions and 0 deletions

View file

@ -0,0 +1,23 @@
**Added:**
* <news item>
**Changed:**
* More stable exception handling in the tab completer.
**Deprecated:**
* <news item>
**Removed:**
* <news item>
**Fixed:**
* <news item>
**Security:**
* <news item>

View file

@ -2,6 +2,7 @@
"""A (tab-)completer for xonsh."""
import builtins
import collections.abc as cabc
from xonsh.tools import print_exception
class Completer(object):
@ -36,6 +37,13 @@ class Completer(object):
out = func(prefix, line, begidx, endidx, ctx)
except StopIteration:
return set(), len(prefix)
except Exception as e:
print_exception(
f"Completer {func.__name__} raises exception when get "
f"(prefix={repr(prefix)}, line={repr(line)}, begidx={repr(begidx)}, endidx={repr(endidx)}):\n"
f"{e}"
)
return set(), len(prefix)
if isinstance(out, cabc.Sequence):
res, lprefix = out
else: