Skip to content

Commit 2d7fb85

Browse files
committed
fix bug invalid data unhandle
1 parent 8094315 commit 2d7fb85

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

discord/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ def __init__(
247247
self.loop: asyncio.AbstractEventLoop = (
248248
asyncio.get_event_loop() if loop is None else loop
249249
)
250-
self._listeners: dict[str, list[tuple[asyncio.Future, Callable[..., bool]]]] = (
251-
{}
252-
)
250+
self._listeners: dict[
251+
str, list[tuple[asyncio.Future, Callable[..., bool]]]
252+
] = {}
253253
self.shard_id: int | None = options.get("shard_id")
254254
self.shard_count: int | None = options.get("shard_count")
255255

@@ -1223,7 +1223,7 @@ async def get_or_fetch(
12231223
object_id=object_id,
12241224
default=default,
12251225
)
1226-
except (HTTPException, ValueError):
1226+
except (HTTPException, ValueError, InvalidData):
12271227
return default
12281228

12291229
# listeners/waiters

discord/guild.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ async def get_or_fetch(
904904
object_id=object_id,
905905
default=default,
906906
)
907-
except (HTTPException, ValueError):
907+
except (HTTPException, ValueError, InvalidData):
908908
return default
909909

910910
@property

discord/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
AppEmoji,
8181
)
8282

83-
from .errors import HTTPException, InvalidArgument
83+
from .errors import HTTPException, InvalidArgument, InvalidData
8484

8585
try:
8686
import msgspec
@@ -682,6 +682,8 @@ async def get_or_fetch(
682682
An error occurred fetching the object.
683683
:exc:`Forbidden`
684684
You do not have permission to fetch the object.
685+
:exc:`InvalidData`
686+
Raised when the object resolves to a different guild.
685687
"""
686688
from discord import Client, Guild, Member, Role, User
687689

@@ -744,7 +746,7 @@ async def get_or_fetch(
744746

745747
try:
746748
return await fetcher(obj, object_id)
747-
except (HTTPException, ValueError):
749+
except (HTTPException, ValueError, InvalidData):
748750
if default is not MISSING:
749751
return default
750752
raise

0 commit comments

Comments
 (0)