diff options
author | Alan Pevec <apevec@redhat.com> | 2019-07-12 01:35:58 +0200 |
---|---|---|
committer | Alan Pevec <apevec@redhat.com> | 2019-07-12 01:35:58 +0200 |
commit | 024dc88011fa2ac31c0d7318096e2ca7f5f2f98a (patch) | |
tree | 8d998cfc0ea539fc5c3df319824b255e03a2873b | |
parent | d484e37816e0dcd9ad472bb12394b7a268e97255 (diff) | |
download | passlib-024dc88011fa2ac31c0d7318096e2ca7f5f2f98a.tar.gz |
Fix for Python 3.8
This was a deprecation when running in Python 3.7:
DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
if isinstance(source, collections.Sequence):
-rw-r--r-- | passlib/utils/__init__.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/passlib/utils/__init__.py b/passlib/utils/__init__.py index d3f9869..058f590 100644 --- a/passlib/utils/__init__.py +++ b/passlib/utils/__init__.py @@ -6,7 +6,12 @@ from passlib.utils.compat import JYTHON # core from binascii import b2a_base64, a2b_base64, Error as _BinAsciiError from base64 import b64encode, b64decode -import collections +try: + from collections.abc import Sequence + from collections.abc import Iterable +except ImportError: + from collections import Sequence + from collections import Iterable from codecs import lookup as _lookup_codec from functools import update_wrapper import itertools @@ -276,14 +281,14 @@ def batch(source, size): """ if size < 1: raise ValueError("size must be positive integer") - if isinstance(source, collections.Sequence): + if isinstance(source, Sequence): end = len(source) i = 0 while i < end: n = i + size yield source[i:n] i = n - elif isinstance(source, collections.Iterable): + elif isinstance(source, Iterable): itr = iter(source) while True: chunk_itr = itertools.islice(itr, size) |