diff --git a/swh/objstorage/backends/libcloud.py b/swh/objstorage/backends/libcloud.py --- a/swh/objstorage/backends/libcloud.py +++ b/swh/objstorage/backends/libcloud.py @@ -4,7 +4,9 @@ # See top-level LICENSE file for more information import abc -import collections +from collections import OrderedDict +from collections.abc import Iterator + from typing import Optional from urllib.parse import urlencode @@ -29,7 +31,7 @@ This is required to properly compute the request signature, see https://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html#ConstructingTheCanonicalizedResourceElement """ # noqa - return urlencode(collections.OrderedDict(sorted(params.items()))) + return urlencode(OrderedDict(sorted(params.items()))) libcloud.storage.drivers.s3.urlencode = s3_urlencode @@ -229,7 +231,7 @@ """ object_path = self._object_path(obj_id) - if not isinstance(content, collections.Iterator): + if not isinstance(content, Iterator): content = (content,) self.driver.upload_object_via_stream( self._compressor(content), self.container, object_path diff --git a/swh/objstorage/backends/pathslicing.py b/swh/objstorage/backends/pathslicing.py --- a/swh/objstorage/backends/pathslicing.py +++ b/swh/objstorage/backends/pathslicing.py @@ -6,7 +6,7 @@ import os import tempfile import random -import collections +from collections.abc import Iterator from itertools import islice from contextlib import contextmanager @@ -245,7 +245,7 @@ return obj_id hex_obj_id = hashutil.hash_to_hex(obj_id) - if not isinstance(content, collections.Iterator): + if not isinstance(content, Iterator): content = [content] compressor = compressors[self.compression]() with _write_obj_file(hex_obj_id, self) as f: diff --git a/swh/objstorage/tests/objstorage_testing.py b/swh/objstorage/tests/objstorage_testing.py --- a/swh/objstorage/tests/objstorage_testing.py +++ b/swh/objstorage/tests/objstorage_testing.py @@ -4,7 +4,7 @@ # See top-level LICENSE file for more information import time -import collections +from collections.abc import Iterator from swh.objstorage import exc from swh.objstorage.objstorage import compute_hash @@ -165,7 +165,7 @@ r = self.storage.get_stream(obj_id, chunk_size=1) except NotImplementedError: return - self.assertTrue(isinstance(r, collections.Iterator)) + self.assertTrue(isinstance(r, Iterator)) r = list(r) self.assertEqual(b"".join(r), content) diff --git a/swh/objstorage/tests/test_objstorage_random_generator.py b/swh/objstorage/tests/test_objstorage_random_generator.py --- a/swh/objstorage/tests/test_objstorage_random_generator.py +++ b/swh/objstorage/tests/test_objstorage_random_generator.py @@ -3,7 +3,7 @@ # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information -from collections import Iterator +from collections.abc import Iterator from swh.objstorage.factory import get_objstorage