From de0a78f90830b136487ca749aa24bcd5ab7ef919 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Wed, 16 Oct 2024 11:52:52 +0900 Subject: [PATCH] Remove Python 3.8 support Python 3.8 is no longer part of the tested runtimes for 2024.2[1] because its EOL is coming soon. Also replace the deprecated md5 wrapper from oslo.utils. [1] https://governance.openstack.org/tc/reference/runtimes/2024.2.html Change-Id: I655bc426213694251a855a54633a10276549c5fe --- releasenotes/notes/remove-py38-5a20e5a2628b9b72.yaml | 5 +++++ setup.cfg | 3 +-- tooz/hashring.py | 9 ++++----- tooz/tests/test_hashring.py | 11 +---------- 4 files changed, 11 insertions(+), 17 deletions(-) create mode 100644 releasenotes/notes/remove-py38-5a20e5a2628b9b72.yaml diff --git a/releasenotes/notes/remove-py38-5a20e5a2628b9b72.yaml b/releasenotes/notes/remove-py38-5a20e5a2628b9b72.yaml new file mode 100644 index 00000000..04031636 --- /dev/null +++ b/releasenotes/notes/remove-py38-5a20e5a2628b9b72.yaml @@ -0,0 +1,5 @@ +--- +upgrade: + - | + Support for Python 3.8 has been removed. Now the minimum python version + supported is 3.9 . diff --git a/setup.cfg b/setup.cfg index 93853cda..9e7883fb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,7 +6,7 @@ summary = Coordination library for distributed systems. description_file = README.rst license = Apache-2 home_page = https://docs.openstack.org/tooz/latest/ -python_requires = >=3.8 +python_requires = >=3.9 classifier = Environment :: OpenStack Intended Audience :: Developers @@ -15,7 +15,6 @@ classifier = Operating System :: POSIX :: Linux Programming Language :: Python Programming Language :: Python :: 3 - Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 diff --git a/tooz/hashring.py b/tooz/hashring.py index 581bc9c2..be6efaeb 100644 --- a/tooz/hashring.py +++ b/tooz/hashring.py @@ -16,8 +16,6 @@ import bisect import hashlib -from oslo_utils.secretutils import md5 - import tooz from tooz import utils @@ -83,7 +81,7 @@ class HashRing(object): for node in nodes: key = utils.to_binary(node, 'utf-8') if self._hash_function == 'md5': - key_hash = md5(key, usedforsecurity=False) + key_hash = hashlib.md5(key, usedforsecurity=False) else: key_hash = hashlib.new(self._hash_function, key) for r in range(self._partition_number * weight): @@ -108,7 +106,7 @@ class HashRing(object): key = utils.to_binary(node, 'utf-8') if self._hash_function == 'md5': - key_hash = md5(key, usedforsecurity=False) + key_hash = hashlib.md5(key, usedforsecurity=False) else: key_hash = hashlib.new(self._hash_function, key) for r in range(self._partition_number * weight): @@ -123,7 +121,8 @@ class HashRing(object): def _get_partition(self, data): if self._hash_function == 'md5': - hashed_key = self._hash2int(md5(data, usedforsecurity=False)) + hashed_key = self._hash2int( + hashlib.md5(data, usedforsecurity=False)) else: hashed_key = self._hash2int( hashlib.new(self._hash_function, data)) diff --git a/tooz/tests/test_hashring.py b/tooz/tests/test_hashring.py index 01dd642f..ea5822ea 100644 --- a/tooz/tests/test_hashring.py +++ b/tooz/tests/test_hashring.py @@ -31,12 +31,6 @@ class HashRingTestCase(testcase.TestCase): # fake -> foo, bar, baz # fake-again -> bar, baz, foo - try: - _ = hashlib.md5(usedforsecurity=False) - _fips_enabled = True - except TypeError: - _fips_enabled = False - @mock.patch.object(hashlib, 'md5', autospec=True) def test_hash2int_returns_int(self, mock_md5): r1 = 32 * 'a' @@ -50,10 +44,7 @@ class HashRingTestCase(testcase.TestCase): self.assertIn(int(r1, 16), ring._ring) self.assertIn(int(r2, 16), ring._ring) - if self._fips_enabled: - mock_md5.assert_called_with(mock.ANY, usedforsecurity=False) - else: - mock_md5.assert_called_with(mock.ANY) + mock_md5.assert_called_with(mock.ANY, usedforsecurity=False) def test_create_ring(self): nodes = {'foo', 'bar'}