From 98ef3be292848950f0c9cc8a5a2a8597daa69ee5 Mon Sep 17 00:00:00 2001 From: Karthikeyan Singaravelan Date: Sat, 1 Feb 2020 00:20:52 +0530 Subject: [PATCH] Import ABC from collections.abc instead of collections for Python 3.9 compatibility. --- misc/table_html_app.py | 5 ++++- tests/test_dictutils.py | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/misc/table_html_app.py b/misc/table_html_app.py index 629325e..94e4726 100644 --- a/misc/table_html_app.py +++ b/misc/table_html_app.py @@ -88,7 +88,10 @@ class BasicRender(object): self.autotable_render = AutoTableRenderer() def render_response(self, request, context, _route): - from collections import Sized + try: + from collections.abc import Sized + except ImportError: + from collections import Sized if isinstance(context, basestring): # already serialized if self._guess_json(context): return Response(context, mimetype="application/json") diff --git a/tests/test_dictutils.py b/tests/test_dictutils.py index 7438d2e..b6873a8 100644 --- a/tests/test_dictutils.py +++ b/tests/test_dictutils.py @@ -88,10 +88,14 @@ def test_clear(): def test_types(): - import collections + try: + from collections.abc import MutableMapping + except ImportError: + from collections import MutableMapping + omd = OMD() assert isinstance(omd, dict) - assert isinstance(omd, collections.MutableMapping) + assert isinstance(omd, MutableMapping) def test_multi_correctness():