﻿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
27058	Reallow the {% for %} tag to unpack any iterable	Sergei Maertens	nobody	"In 1.10 there are now checks done before unpacking in a for loop:

{{{
{% for foo, bar in items %}
    ...
{% endfor %}
}}}

Where it is verified that everey `item` in `items` has `len(item) == 2` in this particular case.

However, the check is implemented so that `len(item)` is taken only if the item is an instance of tuple or list, while custom objects may also implement `def __len__(self):`. Because the custom object does not subclass from tuple or list, it's length is set to 1, leading to ValueErrors.

I have a working patch at https://github.com/django/django/compare/master...sergei-maertens:duck-type-forloop-unpack-len?expand=1, tests are passing. The check no longer checks if the item is an instance of tuple/list, but just tries to get the `len(item)` and handles `TypeError`s.

The only case I could imagine was where the items would be an iterable of strings, but even then it turns out the check is correct (as it is technically possible to unpack strings)."	Cleanup/optimization	closed	Template system	1.10	Normal	fixed			Ready for checkin	1	0	0	0	0	0
