Skip to content

Commit c60ba11

Browse files
authored
Fix deprecated use of collections module
In Python 3.8 imports of abstract base classes directly from the `collections` module will stop working entirely. This change maintains existing behaviour whilst providing backwards compatibility.
1 parent ce92f37 commit c60ba11

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

nameparser/config/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@
2929
unexpected results. See `Customizing the Parser <customize.html>`_.
3030
"""
3131
from __future__ import unicode_literals
32-
import collections
32+
3333
import sys
34+
try:
35+
# Python 3.3+
36+
from collections.abc import Set
37+
except ImportError:
38+
from collections import Set
3439

3540
from nameparser.util import binary_type
3641
from nameparser.util import lc
@@ -45,10 +50,10 @@
4550

4651
DEFAULT_ENCODING = 'UTF-8'
4752

48-
class SetManager(collections.Set):
53+
class SetManager(Set):
4954
'''
5055
Easily add and remove config variables per module or instance. Subclass of
51-
``collections.Set``.
56+
``collections.abc.Set``.
5257
5358
Only special functionality beyond that provided by set() is
5459
to normalize constants for comparison (lower case, no periods)

0 commit comments

Comments
 (0)