aboutsummaryrefslogtreecommitdiffstats
path: root/testing/py3-passlib/0002-Fix-for-Python-3-8.patch
blob: 3fd19a9d5699fd11ee5a92407484a3e6e4695da7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# HG changeset patch
# User Alan Pevec <apevec@redhat.com>
# Date 1562888158 -7200
#      Fri Jul 12 01:35:58 2019 +0200
# 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)