From c7662485b02890efe967ae216a648762f7d8a172 Mon Sep 17 00:00:00 2001 From: Josh Schneier Date: Sat, 16 Sep 2023 23:21:59 -0400 Subject: [PATCH] [s3] fix crash when cleaning up after aborted connection (#1304) --- storages/backends/s3.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/storages/backends/s3.py b/storages/backends/s3.py index 497b0e99..3edc3c9a 100644 --- a/storages/backends/s3.py +++ b/storages/backends/s3.py @@ -251,8 +251,9 @@ def _create_empty_on_close(self): def close(self): if self._is_dirty: - self._flush_write_buffer() - self._multipart.complete(MultipartUpload={"Parts": self._parts}) + if self._multipart is not None: + self._flush_write_buffer() + self._multipart.complete(MultipartUpload={"Parts": self._parts}) else: if self._multipart is not None: self._multipart.abort()