Raise exception if given a bad topic name (#824)
This commit is contained in:
committed by
Dana Powers
parent
07237d9894
commit
5ad6f52a80
@@ -128,15 +128,22 @@ class SubscriptionState(object):
|
||||
|
||||
Raises:
|
||||
IllegalStateErrror: if assign_from_user has been used already
|
||||
TypeError: if a non-str topic is given
|
||||
"""
|
||||
if self._user_assignment:
|
||||
raise IllegalStateError(self._SUBSCRIPTION_EXCEPTION_MESSAGE)
|
||||
|
||||
if isinstance(topics, str):
|
||||
topics = [topics]
|
||||
|
||||
if self.subscription == set(topics):
|
||||
log.warning("subscription unchanged by change_subscription(%s)",
|
||||
topics)
|
||||
return
|
||||
|
||||
if any(not isinstance(t, str) for t in topics):
|
||||
raise TypeError('All topics must be strings')
|
||||
|
||||
log.info('Updating subscribed topics to: %s', topics)
|
||||
self.subscription = set(topics)
|
||||
self._group_subscription.update(topics)
|
||||
|
||||
Reference in New Issue
Block a user