From b8e7ef305fbc39d47ebed427f28fa0675fd06734 Mon Sep 17 00:00:00 2001 From: mdumandag Date: Tue, 23 Mar 2021 15:27:17 +0300 Subject: [PATCH] Do not use deprecated abstract classes from collections Abstract classes Sequence and Iterable are meant to be imported from `collections.abc` instead of `collections` starting from Python 3.3. Since the minimum supported Python version for the client is 3.4, we can safely try to import it from the new location and fallback to the old location if the import fails. It will only fail for the Python 2.7 in which it is fine to import those abstact classes from `collections`. --- hazelcast/util.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hazelcast/util.py b/hazelcast/util.py index 732759fd92..6accedfa06 100644 --- a/hazelcast/util.py +++ b/hazelcast/util.py @@ -1,7 +1,12 @@ import random import threading import time -from collections import Sequence, Iterable + +try: + from collections.abc import Sequence, Iterable +except ImportError: + # Compatibility for Python2 + from collections import Sequence, Iterable from hazelcast import six