Skip to content

Commit e32f341

Browse files
authored
Do not use deprecated abstract classes from collections (#385)
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`.
1 parent e259d86 commit e32f341

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

hazelcast/util.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import random
22
import threading
33
import time
4-
from collections import Sequence, Iterable
4+
5+
try:
6+
from collections.abc import Sequence, Iterable
7+
except ImportError:
8+
# Compatibility for Python2
9+
from collections import Sequence, Iterable
510

611
from hazelcast import six
712

0 commit comments

Comments
 (0)