From 0425dbe0473b0ce6c508884e8320eb008ca4ef13 Mon Sep 17 00:00:00 2001 From: tzing_t Date: Fri, 31 May 2024 07:44:23 +0000 Subject: [PATCH] Replace deprecated import ABCs from collections --- ...recated_import_ABCs_from_collections.patch | 71 +++++++++++++++++++ openstack-swift.spec | 9 ++- 2 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 Replace_deprecated_import_ABCs_from_collections.patch diff --git a/Replace_deprecated_import_ABCs_from_collections.patch b/Replace_deprecated_import_ABCs_from_collections.patch new file mode 100644 index 0000000..5d7f11b --- /dev/null +++ b/Replace_deprecated_import_ABCs_from_collections.patch @@ -0,0 +1,71 @@ +diff --git a/swift/common/middleware/crypto/crypto_utils.py b/swift/common/middleware/crypto/crypto_utils.py +index 60fe7c2..43f93ce 100644 +--- a/swift/common/middleware/crypto/crypto_utils.py ++++ b/swift/common/middleware/crypto/crypto_utils.py +@@ -14,7 +14,6 @@ + # limitations under the License. + import base64 + import binascii +-import collections + import json + import os + +@@ -260,7 +259,7 @@ def load_crypto_meta(value, b64decode=True): + if not isinstance(value, six.string_types): + raise ValueError('crypto meta not a string') + val = json.loads(urlparse.unquote_plus(value)) +- if not isinstance(val, collections.Mapping): ++ if not isinstance(val, dict): + raise ValueError('crypto meta not a Mapping') + return b64_decode_meta(val) + except (KeyError, ValueError, TypeError) as err: +diff --git a/swift/common/middleware/s3api/s3response.py b/swift/common/middleware/s3api/s3response.py +index 3ba4018..cd690e3 100644 +--- a/swift/common/middleware/s3api/s3response.py ++++ b/swift/common/middleware/s3api/s3response.py +@@ -14,7 +14,10 @@ + # limitations under the License. + + import re +-from collections import MutableMapping ++try: ++ from collections.abc import MutableMapping ++except ImportError: ++ from collections import MutableMapping # py2 + from functools import partial + + from swift.common import header_key_dict +diff --git a/swift/common/swob.py b/swift/common/swob.py +index 76fb2fb..6eaa33a 100644 +--- a/swift/common/swob.py ++++ b/swift/common/swob.py +@@ -35,7 +35,11 @@ place to keep Swift working every time webob decides some interface + needs to change. + """ + +-from collections import defaultdict, MutableMapping ++from collections import defaultdict ++try: ++ from collections.abc import MutableMapping ++except ImportError: ++ from collections import MutableMapping # py2 + import time + from functools import partial + from datetime import datetime +diff --git a/test/unit/__init__.py b/test/unit/__init__.py +index 5b768c4..a397dc0 100644 +--- a/test/unit/__init__.py ++++ b/test/unit/__init__.py +@@ -22,7 +22,11 @@ import logging + import logging.handlers + import sys + from contextlib import contextmanager, closing +-from collections import defaultdict, Iterable ++from collections import defaultdict ++try: ++ from collections.abc import Iterable ++except ImportError: ++ from collections import Iterable # py2 + import itertools + from numbers import Number + from tempfile import NamedTemporaryFile diff --git a/openstack-swift.spec b/openstack-swift.spec index 44f081e..cd7e559 100644 --- a/openstack-swift.spec +++ b/openstack-swift.spec @@ -16,7 +16,7 @@ expensive equipment. Name: openstack-swift Version: 2.27.0 -Release: 5 +Release: 6 Summary: OpenStack Object Storage License: ASL 2.0 URL: https://docs.openstack.org/swift/latest/ @@ -67,6 +67,8 @@ Source75: %{name}-container-sync.service Source76: %{name}-container-sync@.service Source77: internal-client.conf +Patch001: Replace_deprecated_import_ABCs_from_collections.patch + BuildArch: noarch BuildRequires: openstack-macros @@ -208,7 +210,7 @@ This package contains documentation files for %{name}. %prep # Required for tarball sources verification -%autosetup -n swift-%{upstream_version} -S git +%autosetup -n swift-%{upstream_version} -S git -p1 # Let RPM handle the dependencies %py_req_cleanup @@ -580,6 +582,9 @@ exit 0 %endif %changelog +* Sat May 25 2024 tzing_t - 2.27.0-6 +- Replace deprecated import ABCs from collections + * Mon Aug 30 2021 wangixyuan - 2.27.0-5 - Update swift service config file content. -- Gitee