diff options
Diffstat (limited to 'django/utils')
| -rw-r--r-- | django/utils/hashable.py | 4 | ||||
| -rw-r--r-- | django/utils/itercompat.py | 13 |
2 files changed, 15 insertions, 2 deletions
diff --git a/django/utils/hashable.py b/django/utils/hashable.py index 042e1a4373..323dfe74e7 100644 --- a/django/utils/hashable.py +++ b/django/utils/hashable.py @@ -1,4 +1,4 @@ -from django.utils.itercompat import is_iterable +from collections.abc import Iterable def make_hashable(value): @@ -19,7 +19,7 @@ def make_hashable(value): try: hash(value) except TypeError: - if is_iterable(value): + if isinstance(value, Iterable): return tuple(map(make_hashable, value)) # Non-hashable, non-iterable. raise diff --git a/django/utils/itercompat.py b/django/utils/itercompat.py index 9895e3f816..e4b34cd534 100644 --- a/django/utils/itercompat.py +++ b/django/utils/itercompat.py @@ -1,5 +1,18 @@ +# RemovedInDjango60Warning: Remove this entire module. + +import warnings + +from django.utils.deprecation import RemovedInDjango60Warning + + def is_iterable(x): "An implementation independent way of checking for iterables" + warnings.warn( + "django.utils.itercompat.is_iterable() is deprecated. " + "Use isinstance(..., collections.abc.Iterable) instead.", + RemovedInDjango60Warning, + stacklevel=2, + ) try: iter(x) except TypeError: |
