From 024dc88011fa2ac31c0d7318096e2ca7f5f2f98a Mon Sep 17 00:00:00 2001 From: Alan Pevec Date: Fri, 12 Jul 2019 01:35:58 +0200 Subject: 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): --- passlib/utils/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'passlib/utils') 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) -- cgit v1.2.1