Handle collections.abc deprecations

The use of ABC classes directly from collections has been deprecated in
3.x versions of Python. The direction is to use the classes defined in
collections.abc. Python 2.7 does not have this, but Python 3.8 will be
dropping the backwards compatibility to use the old location.

Six also does not have support for this yet, so in the mean time to make
sure we don't run into issues as folks try to move to 3.8, and to get
rid of deprecation warnings in logs, this handles importing from the
preferred location and falls back if it not available.

Change-Id: If67133813634f41d89ccdf0f6d6d5ffa66c97dd8
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This commit is contained in:
Sean McGinnis 2019-04-09 16:43:16 -05:00
parent 44bd971bfb
commit 4d48b33a41

View File

@ -15,7 +15,13 @@
# License for the specific language governing permissions and limitations
# under the License.
import collections
# TODO(smcginnis) update this once six has support for collections.abc
# (https://github.com/benjaminp/six/pull/241) or clean up once we drop py2.7.
try:
from collections.abc import Mapping
except ImportError:
from collections import Mapping
import copy
import logging
import sys
@ -481,7 +487,7 @@ class ConnectionContext(Connection):
raise InvalidRPCConnectionReuse()
class ConfigOptsProxy(collections.Mapping):
class ConfigOptsProxy(Mapping):
"""Proxy for oslo_config.cfg.ConfigOpts.
Values from the query part of the transport url (if they are both present
@ -518,7 +524,7 @@ class ConfigOptsProxy(collections.Mapping):
def __len__(self):
return len(self._conf)
class GroupAttrProxy(collections.Mapping):
class GroupAttrProxy(Mapping):
"""Internal helper proxy for oslo_config.cfg.ConfigOpts.GroupAttr."""
_VOID_MARKER = object()