Fix Python 3.8 compatibility (#6154)

This commit is contained in:
Jerome Leclanche 2018-09-11 07:12:32 +03:00 committed by Ryan P Kilby
parent 4d57d46bf8
commit 612a7b989f
2 changed files with 9 additions and 2 deletions

View File

@ -10,6 +10,13 @@ from django.core import validators
from django.utils import six from django.utils import six
from django.views.generic import View from django.views.generic import View
try:
# Python 3 (required for 3.8+)
from collections.abc import Mapping # noqa
except ImportError:
# Python 2.7
from collections import Mapping # noqa
try: try:
from django.urls import ( # noqa from django.urls import ( # noqa
URLPattern, URLPattern,

View File

@ -15,7 +15,7 @@ from __future__ import unicode_literals
import copy import copy
import inspect import inspect
import traceback import traceback
from collections import Mapping, OrderedDict from collections import OrderedDict
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
from django.core.exceptions import ValidationError as DjangoValidationError from django.core.exceptions import ValidationError as DjangoValidationError
@ -27,7 +27,7 @@ from django.utils import six, timezone
from django.utils.functional import cached_property from django.utils.functional import cached_property
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from rest_framework.compat import postgres_fields, unicode_to_repr from rest_framework.compat import Mapping, postgres_fields, unicode_to_repr
from rest_framework.exceptions import ErrorDetail, ValidationError from rest_framework.exceptions import ErrorDetail, ValidationError
from rest_framework.fields import get_error_detail, set_value from rest_framework.fields import get_error_detail, set_value
from rest_framework.settings import api_settings from rest_framework.settings import api_settings