From 024cbdc4fb39fab78545b3d7175ddf42c532c5f4 Mon Sep 17 00:00:00 2001 From: Lars Rinn Date: Thu, 17 Jan 2019 23:08:28 +0100 Subject: [PATCH] import collections.ABCs from correct module (#992) * import collectionss.ABCs from correct model to silence deprecation warnings * fix imports for legacy python --- kombu/utils/functional.py | 8 +++++++- kombu/utils/url.py | 6 +++++- t/unit/transport/test_qpid.py | 8 +++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/kombu/utils/functional.py b/kombu/utils/functional.py index 252b757e..63395a39 100644 --- a/kombu/utils/functional.py +++ b/kombu/utils/functional.py @@ -5,7 +5,13 @@ import random import sys import threading -from collections import Iterable, Mapping, OrderedDict +from collections import OrderedDict + +try: + from collections.abc import Iterable, Mapping +except ImportError: + from collections import Iterable, Mapping + from itertools import count, repeat from time import sleep, time diff --git a/kombu/utils/url.py b/kombu/utils/url.py index fbc90a14..b86f2f6f 100644 --- a/kombu/utils/url.py +++ b/kombu/utils/url.py @@ -1,7 +1,11 @@ """URL Utilities.""" from __future__ import absolute_import, unicode_literals -from collections import Mapping +try: + from collections.abc import Mapping +except ImportError: + from collections import Mapping + from functools import partial try: diff --git a/t/unit/transport/test_qpid.py b/t/unit/transport/test_qpid.py index 5ca4f38a..ae2de8ba 100644 --- a/t/unit/transport/test_qpid.py +++ b/t/unit/transport/test_qpid.py @@ -8,7 +8,13 @@ import sys import time import uuid -from collections import Callable, OrderedDict +from collections import OrderedDict + +try: + from collections.abc import Callable +except ImportError: + from collections import Callable + from itertools import count from case import Mock, call, patch, skip