﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34983	Deprecate django.utils.itercompat.is_iterable().	Nick Pope	Nick Pope	"While reviewing the [https://github.com/django/django/pull/17368 PR] for #10941, I saw that we are still using the `django.utils.itercompat.is_iterable()` helper function.

It seems that this was originally added in ad077ccbc03f11c3db3951aab110ec98c5907729 to fix #5445 back in 2007. This was required because Jython 2.2 didn't have support for `__iter__()`. Django's support for Jython was removed in 2017 in #28954.

As pointed out in [https://github.com/django/django/pull/17368#discussion_r1372842813 this comment], `is_iterable()` also handles the older fallback to determining if something is iterable by the presence of `__getitem__()` as mentioned in Python's [https://docs.python.org/3.12/library/collections.abc.html#id19 documentation]:

> Checking `isinstance(obj, Iterable)` detects classes that are registered as `Iterable` or that have an `__iter__()` method, but it does not detect classes that iterate with the `__getitem__()` method. The only reliable way to determine whether an object is iterable is to call `iter(obj)`.

In practice, however, it is rare that iterables do not support `__iter__()` and, for all uses of this internal function, it doesn't seem to be necessary.

I propose that we replace this function with the more standard `isinstance(..., collections.abc.Iterable)` and deprecate it. ''(Although the function is private and undocumented, it is likely used in the wild and other past functions from this module have been through a deprecation process.)''"	Cleanup/optimization	closed	Utilities	dev	Normal	fixed	itercompat, is_iterable	Carsten Fuchs	Ready for checkin	1	0	0	0	0	0
