Skip to content

Commit 612a7b9

Browse files
jleclancherpkilby
authored andcommitted
Fix Python 3.8 compatibility (#6154)
1 parent 4d57d46 commit 612a7b9

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

rest_framework/compat.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
from django.utils import six
1111
from django.views.generic import View
1212

13+
try:
14+
# Python 3 (required for 3.8+)
15+
from collections.abc import Mapping # noqa
16+
except ImportError:
17+
# Python 2.7
18+
from collections import Mapping # noqa
19+
1320
try:
1421
from django.urls import ( # noqa
1522
URLPattern,

rest_framework/serializers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import copy
1616
import inspect
1717
import traceback
18-
from collections import Mapping, OrderedDict
18+
from collections import OrderedDict
1919

2020
from django.core.exceptions import ImproperlyConfigured
2121
from django.core.exceptions import ValidationError as DjangoValidationError
@@ -27,7 +27,7 @@
2727
from django.utils.functional import cached_property
2828
from django.utils.translation import ugettext_lazy as _
2929

30-
from rest_framework.compat import postgres_fields, unicode_to_repr
30+
from rest_framework.compat import Mapping, postgres_fields, unicode_to_repr
3131
from rest_framework.exceptions import ErrorDetail, ValidationError
3232
from rest_framework.fields import get_error_detail, set_value
3333
from rest_framework.settings import api_settings

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy