From d863a87cba95cb3bf1cdee7be2e57c2af9657d41 Mon Sep 17 00:00:00 2001 From: SubaruArai <78188579+SubaruArai@users.noreply.github.com> Date: Tue, 26 Sep 2023 23:24:19 +0900 Subject: [PATCH] fix: topic list crashes if no topics are available (#869) This is due to the function expecting an object unpackable to 2 iterables, but an empty iterable is returned if no topics are available. This happens only when using glob, which might have been the reason why this bug was not caught earlier. --- rosapi/src/rosapi/proxy.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rosapi/src/rosapi/proxy.py b/rosapi/src/rosapi/proxy.py index 56e28c75a..b7bfb9bd1 100644 --- a/rosapi/src/rosapi/proxy.py +++ b/rosapi/src/rosapi/proxy.py @@ -65,9 +65,13 @@ def get_topics_and_types(topics_glob): # Add topics with unknown type messages. unknown_type = topics.difference([x for x, _ in topic_types]) - return zip(* topic_types + [[x,''] for x in unknown_type]) + topic_types.extend([[x, ''] for x in unknown_type]) + if topic_types: + return zip(*topic_types) + else: + return [], [] except: - return [] + return [], [] def get_topics_for_type(type, topics_glob):