diff options
| author | Nick Pope <nick@nickpope.me.uk> | 2023-11-24 11:06:29 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-24 12:06:29 +0100 |
| commit | 5e28cd3f2cfc31bf947a747256bc036f8f64888a (patch) | |
| tree | 7f687c30cd0bec4aec9837c7b311b616ebd8c4e1 /django/utils | |
| parent | eabfa2d0e38670365aa74117ad2f8710b81065c5 (diff) | |
Fixed #34983 -- Deprecated django.utils.itercompat.is_iterable().
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: |
