From 06ca5184596d187b1737484b265d847b8efb3dc1 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Wed, 11 Jan 2017 19:53:29 -0500 Subject: [PATCH] Rename NoMoreMessages to NoMoreItems. --- discord/abc.py | 6 +++--- discord/errors.py | 7 ++++--- discord/iterators.py | 6 +++--- docs/api.rst | 2 ++ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/discord/abc.py b/discord/abc.py index 0cae7b494..4cd288d1d 100644 --- a/discord/abc.py +++ b/discord/abc.py @@ -33,7 +33,7 @@ from collections import namedtuple from .iterators import HistoryIterator from .context_managers import Typing -from .errors import ClientException, NoMoreMessages, InvalidArgument +from .errors import ClientException, NoMoreItems, InvalidArgument from .permissions import PermissionOverwrite, Permissions from .role import Role from . import utils, compat @@ -740,7 +740,7 @@ class Messageable(metaclass=abc.ABCMeta): while True: try: message = yield from iterator.get() - except discord.NoMoreMessages: + except discord.NoMoreItems: break else: if message.author == client.user: @@ -813,7 +813,7 @@ class Messageable(metaclass=abc.ABCMeta): while True: try: msg = yield from iterator.get() - except NoMoreMessages: + except NoMoreItems: # no more messages to poll if count >= 2: # more than 2 messages -> bulk delete diff --git a/discord/errors.py b/discord/errors.py index 46751b627..795c0bf69 100644 --- a/discord/errors.py +++ b/discord/errors.py @@ -38,9 +38,10 @@ class ClientException(DiscordException): """ pass -class NoMoreMessages(DiscordException): - """Exception that is thrown when a ``history`` operation has no more - messages. This is only exposed for Python 3.4 only. +class NoMoreItems(DiscordException): + """Exception that is thrown when an async iteration operation has no more + items. This is mainly exposed for Python 3.4 support where `StopAsyncIteration` + is not provided. """ pass diff --git a/discord/iterators.py b/discord/iterators.py index 8e535a7e9..e1de1ddb8 100644 --- a/discord/iterators.py +++ b/discord/iterators.py @@ -29,7 +29,7 @@ import asyncio import aiohttp import datetime -from .errors import NoMoreMessages +from .errors import NoMoreItems from .utils import time_snowflake from .object import Object @@ -132,7 +132,7 @@ class HistoryIterator: try: return self.messages.get_nowait() except asyncio.QueueEmpty: - raise NoMoreMessages() + raise NoMoreItems() @asyncio.coroutine def flatten(self): @@ -217,7 +217,7 @@ class HistoryIterator: try: msg = yield from self.get() return msg - except NoMoreMessages: + except NoMoreItems: # if we're still empty at this point... # we didn't get any new messages so stop looping raise StopAsyncIteration() diff --git a/docs/api.rst b/docs/api.rst index c3f6aabcf..1855e5ac7 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -782,6 +782,8 @@ The following exceptions are thrown by the library. .. autoexception:: LoginFailure +.. autoexception:: NoMoreItems + .. autoexception:: HTTPException :members: