Import ABCs from collections.abc

Python 3 has moved all collection abstract base classes to
collections.abc. Python 3.7 started to deprecate the old aliases.

The whole import block needs to be protected with import-error and
no-name-in-module, because Python 2 doesn't have collections.abc module and
collections.abc.Mapping, while Python 3 doesn't have collections.Mapping.

Fixes: https://pagure.io/freeipa/issue/7609
Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Fraser Tweedale <ftweedal@redhat.com>
This commit is contained in:
Christian Heimes
2018-07-04 10:07:49 +02:00
parent 53c5496647
commit 198a2c6112
8 changed files with 71 additions and 17 deletions

View File

@@ -27,7 +27,6 @@ import datetime
from decimal import Decimal
from copy import deepcopy
import contextlib
import collections
import os
import pwd
import warnings
@@ -53,6 +52,13 @@ from ipapython.dn import DN
from ipapython.dnsutil import DNSName
from ipapython.kerberos import Principal
# pylint: disable=no-name-in-module, import-error
if six.PY3:
from collections.abc import MutableMapping
else:
from collections import MutableMapping
# pylint: enable=no-name-in-module, import-error
if six.PY3:
unicode = str
@@ -213,7 +219,7 @@ class SchemaCache(object):
schema_cache = SchemaCache()
class LDAPEntry(collections.MutableMapping):
class LDAPEntry(MutableMapping):
__slots__ = ('_conn', '_dn', '_names', '_nice', '_raw', '_sync',
'_not_list', '_orig_raw', '_raw_view',
'_single_value_view')
@@ -577,7 +583,7 @@ class LDAPEntry(collections.MutableMapping):
return iter(self._nice)
class LDAPEntryView(collections.MutableMapping):
class LDAPEntryView(MutableMapping):
__slots__ = ('_entry',)
def __init__(self, entry):