aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/python/py-cmd.c2
-rw-r--r--gdb/testsuite/gdb.python/py-completion.exp5
-rw-r--r--gdb/testsuite/gdb.python/py-completion.py12
3 files changed, 18 insertions, 1 deletions
diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c
index 20a384d..d3845fc 100644
--- a/gdb/python/py-cmd.c
+++ b/gdb/python/py-cmd.c
@@ -290,7 +290,7 @@ cmdpy_completer (struct cmd_list_element *command,
else if (value >= 0 && value < (long) N_COMPLETERS)
completers[value].completer (command, tracker, text, word);
}
- else
+ else if (PySequence_Check (resultobj.get ()))
{
gdbpy_ref<> iter (PyObject_GetIter (resultobj.get ()));
diff --git a/gdb/testsuite/gdb.python/py-completion.exp b/gdb/testsuite/gdb.python/py-completion.exp
index 23f981e..89843c9 100644
--- a/gdb/testsuite/gdb.python/py-completion.exp
+++ b/gdb/testsuite/gdb.python/py-completion.exp
@@ -46,6 +46,11 @@ if { [readline_is_used] && ![is_remote host] } {
# Just discarding whatever we typed.
gdb_test " " ".*" "discard #[incr discard]"
+ # This should offer no suggestions - the complete() methods
+ # returns something that is neither an integer, or a sequence.
+ gdb_test_no_output "complete completefilenone ${testdir_complete}" \
+ "no suggestions given"
+
# This is the problematic one.
send_gdb "completefilemethod ${testdir_complete}\t"
gdb_test_multiple "" "completefilemethod completion" {
diff --git a/gdb/testsuite/gdb.python/py-completion.py b/gdb/testsuite/gdb.python/py-completion.py
index abec069..61b6bef 100644
--- a/gdb/testsuite/gdb.python/py-completion.py
+++ b/gdb/testsuite/gdb.python/py-completion.py
@@ -28,6 +28,17 @@ class CompleteFileInit(gdb.Command):
raise gdb.GdbError("not implemented")
+class CompleteFileNone(gdb.Command):
+ def __init__(self):
+ gdb.Command.__init__(self, "completefilenone", gdb.COMMAND_USER)
+
+ def invoke(self, argument, from_tty):
+ raise gdb.GdbError("not implemented")
+
+ def complete(self, text, word):
+ return None
+
+
class CompleteFileMethod(gdb.Command):
def __init__(self):
gdb.Command.__init__(self, "completefilemethod", gdb.COMMAND_USER)
@@ -203,6 +214,7 @@ class CompleteLimit7(gdb.Command):
CompleteFileInit()
+CompleteFileNone()
CompleteFileMethod()
CompleteFileCommandCond()
CompleteLimit1()