1
0
python-passlib/pr_9_1.patch
2019-10-04 07:43:58 +00:00

48 lines
1.5 KiB
Diff

# HG changeset patch
# User Alan Pevec <apevec@redhat.com>
# Date 1562888158 -7200
# Branch stable
# Node ID 98c08467d15759acc3b0f88d2661f6e530147c33
# Parent 27866c441d18c7ce42e3f7afe824f89da4f8d21b
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):
diff --git a/passlib/utils/__init__.py b/passlib/utils/__init__.py
--- a/passlib/utils/__init__.py
+++ b/passlib/utils/__init__.py
@@ -6,7 +6,12 @@
# 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 @@
"""
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)