Import ABC from collections.abc instead of collections for Python 3.9 compatibility.

This commit is contained in:
Karthikeyan Singaravelan 2020-02-01 00:20:52 +05:30
parent eefa5ee604
commit 98ef3be292
2 changed files with 10 additions and 3 deletions

View File

@ -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")

View File

@ -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():