From 70cc47ba8bea5e43dae54e1802ebbe5da2032d6f Mon Sep 17 00:00:00 2001 From: andrei Date: Wed, 7 Jun 2017 17:26:34 -0700 Subject: [PATCH] remove usages of StopIteration to remove warnings on py3 this was due to pep479 --- disco/bot/bot.py | 6 +++--- disco/types/channel.py | 2 +- disco/util/functional.py | 2 +- disco/util/paginator.py | 2 +- disco/voice/playable.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/disco/bot/bot.py b/disco/bot/bot.py index 1a64d67..b88d6f1 100644 --- a/disco/bot/bot.py +++ b/disco/bot/bot.py @@ -275,7 +275,7 @@ class Bot(LoggingClass): mention_rules.get('role', False) and any(mention_roles), msg.channel.is_dm )): - raise StopIteration + return if mention_direct: if msg.guild: @@ -296,12 +296,12 @@ class Bot(LoggingClass): content = content.lstrip() if prefix and not content.startswith(prefix): - raise StopIteration + return else: content = content[len(prefix):] if not self.command_matches_re or not self.command_matches_re.match(content): - raise StopIteration + return for command in self.commands: match = command.compiled_regex.match(content) diff --git a/disco/types/channel.py b/disco/types/channel.py index a06255e..853ca40 100644 --- a/disco/types/channel.py +++ b/disco/types/channel.py @@ -432,7 +432,7 @@ class MessageIterator(object): limit=self.chunk_size) if not len(self._buffer): - raise StopIteration + return self.after = None self.before = None diff --git a/disco/util/functional.py b/disco/util/functional.py index ee0ac02..29921a3 100644 --- a/disco/util/functional.py +++ b/disco/util/functional.py @@ -17,7 +17,7 @@ def take(seq, count): for _ in range(count): i = next(seq, NO_MORE_SENTINEL) if i is NO_MORE_SENTINEL: - raise StopIteration + return yield i diff --git a/disco/util/paginator.py b/disco/util/paginator.py index f690cff..715f8d9 100644 --- a/disco/util/paginator.py +++ b/disco/util/paginator.py @@ -20,7 +20,7 @@ class Paginator(object): result = self.func(*self.args, **self.kwargs) if not len(result): - raise StopIteration + return self._buffer.extend(result) self._after = self._key(result[-1]) diff --git a/disco/voice/playable.py b/disco/voice/playable.py index 55d80fa..35fbf8b 100644 --- a/disco/voice/playable.py +++ b/disco/voice/playable.py @@ -183,7 +183,7 @@ class YoutubeDLInput(FFmpegInput): if 'entries' not in info: yield cls(ie_info=info, *args, **kwargs) - raise StopIteration + return for item in info['entries']: yield cls(ie_info=item, *args, **kwargs)