From d2da9effa11b88d2be4ff19046f0e0114707bfa6 Mon Sep 17 00:00:00 2001 From: Paillat Date: Thu, 6 Nov 2025 17:18:14 +0100 Subject: [PATCH 1/3] :recycle: Make `Attachment.save` clearer by expliciting that chunksize is non-null --- discord/message.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/discord/message.py b/discord/message.py index ad2e986ec8..62651003dc 100644 --- a/discord/message.py +++ b/discord/message.py @@ -314,7 +314,7 @@ async def save( deleted attachments if too much time has passed, and it does not work on some types of attachments. chunksize: Optional[:class:`int`] - The maximum size of each chunk to process. + The maximum size of each chunk to process. Must be a positive non-null integer. Returns ------- @@ -336,7 +336,7 @@ async def save( data = await self.read(use_cached=use_cached) if isinstance(fp, io.BufferedIOBase): - if chunksize: + if chunksize is not None: written = 0 async for chunk in data: written += fp.write(chunk) @@ -347,7 +347,7 @@ async def save( return written else: with open(fp, "wb") as f: - if chunksize: + if chunksize is not None: written = 0 async for chunk in data: written += f.write(chunk) @@ -400,7 +400,7 @@ async def read_chunked( Parameters ---------- chunksize: :class:`int` - The maximum size of each chunk to process. + The maximum size of each chunk to process. Must be a positive non-null integer. use_cached: :class:`bool` Whether to use :attr:`proxy_url` rather than :attr:`url` when downloading the attachment. This will allow attachments to be saved after deletion From 44a5e7fa385da6071142bb9101c644c3a3644622 Mon Sep 17 00:00:00 2001 From: Paillat Date: Thu, 6 Nov 2025 20:08:26 +0100 Subject: [PATCH 2/3] Update discord/message.py Co-authored-by: plun1331 Signed-off-by: Paillat --- discord/message.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/message.py b/discord/message.py index 62651003dc..3e72f5b3e6 100644 --- a/discord/message.py +++ b/discord/message.py @@ -314,7 +314,7 @@ async def save( deleted attachments if too much time has passed, and it does not work on some types of attachments. chunksize: Optional[:class:`int`] - The maximum size of each chunk to process. Must be a positive non-null integer. + The maximum size of each chunk to process. Must be a positive integer. Returns ------- From e2532d9120ce0dff375ddcd442c5d8464b17d3c3 Mon Sep 17 00:00:00 2001 From: Paillat Date: Thu, 6 Nov 2025 20:08:33 +0100 Subject: [PATCH 3/3] Update discord/message.py Co-authored-by: plun1331 Signed-off-by: Paillat --- discord/message.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/message.py b/discord/message.py index 3e72f5b3e6..2ef90bdd9e 100644 --- a/discord/message.py +++ b/discord/message.py @@ -400,7 +400,7 @@ async def read_chunked( Parameters ---------- chunksize: :class:`int` - The maximum size of each chunk to process. Must be a positive non-null integer. + The maximum size of each chunk to process. Must be a positive integer. use_cached: :class:`bool` Whether to use :attr:`proxy_url` rather than :attr:`url` when downloading the attachment. This will allow attachments to be saved after deletion