From 3e8d62715eb206ddb2eda093cb91d5da5f36397c Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Tue, 12 Nov 2024 16:17:19 +0900 Subject: [PATCH] CPLAT-4620 patch to use collections.abc in python3 --- django/core/paginator.py | 7 +++++-- django/db/models/sql/query.py | 8 +++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/django/core/paginator.py b/django/core/paginator.py index f149598203f0..44e441242176 100644 --- a/django/core/paginator.py +++ b/django/core/paginator.py @@ -121,9 +121,12 @@ def _check_object_list_is_ordered(self): QuerySetPaginator = Paginator # For backwards-compatibility. +try: + from collections.abc import Sequence +except ImportError: + from collections import Sequence - -class Page(collections.Sequence): +class Page(Sequence): def __init__(self, object_list, number, paginator): self.object_list = object_list diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index e51b1037ca30..c4897f4dab98 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -8,7 +8,13 @@ """ import copy import warnings -from collections import Counter, Iterator, Mapping, OrderedDict +from collections import Counter, OrderedDict +try: + from collections.abc import Iterable + from collections.abc import MutableMapping +except ImportError: + from collections import Iterable + from collections import MutableMapping from itertools import chain, count, product from string import ascii_uppercase