From f783dd54a2a81bbd7a03b17e26a5563199c52015 Mon Sep 17 00:00:00 2001
From: Marcus Müller <marcus.mueller@ettus.com>
Date: Fri, 9 Feb 2018 00:31:23 +0100
Subject: modtool: SequenceCompleter has default [] sequence

Fixes #1602, where SequenceCompleter was called from `gr_modtool rm`
without any argument.

Note that the longer-term goal is still to amend the `rm` statement's
code to prepare a good list of candidates instead of reducing the usage
of SequenceCompleter to just enabling readline editing capabilities.
---
 gr-utils/python/modtool/util_functions.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

(limited to 'gr-utils/python/modtool/util_functions.py')

diff --git a/gr-utils/python/modtool/util_functions.py b/gr-utils/python/modtool/util_functions.py
index b20970175c..9a949c8031 100644
--- a/gr-utils/python/modtool/util_functions.py
+++ b/gr-utils/python/modtool/util_functions.py
@@ -150,10 +150,13 @@ class SequenceCompleter(object):
     """ A simple completer function wrapper to be used with readline, e.g.
     option_iterable = ("search", "seek", "destroy")
     readline.set_completer(SequenceCompleter(option_iterable).completefunc)
+
+    Typical usage is with the `with` statement. Restores the previous completer
+    at exit, thus nestable.
     """
 
-    def __init__(self, sequence):
-        self._seq = sequence
+    def __init__(self, sequence=None):
+        self._seq = sequence or []
         self._tmp_matches = []
 
     def completefunc(self, text, state):
-- 
cgit v1.2.3