#27058: {% for %} tag unpacking: less strict checks
--------------------------------------+------------------------------------
     Reporter:  sergei-maertens       |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  Template system       |                  Version:  1.10
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------

Comment (by sergei-maertens):

 Replying to [comment:2 timgraham]:
 > Here's a test case that passes on master but fails with your proposed
 patch. As to whether or not that's a case to protect against, I guess it's
 probably better to assume that the programmer won't make a mistake like
 that if it prevents other use cases.
 > {{{#!python
 > @setup({'for-tag-unpack15': '{% for x,y in items %}{{ x }}:{{ y }}/{%
 endfor %}'})
 > def test_for_tag_unpack15(self):
 >     with self.assertRaisesMessage(ValueError, 'Need 2 values to unpack
 in for loop; got 1.'):
 >         self.engine.render_to_string('for-tag-unpack15', {'items':
 ('ab', 'ac')})
 > }}}

 Ah yes, this was the test case I was trying to come up with because I
 _knew_ there was something with checking string lengths. I think I would
 classify this test case as incorrect, since in pure python `for x, y in
 ('ab', 'ac'):` is correct as well. I'd call this a logical programmer
 error that's the responsability of the end-user.

--
Ticket URL: <https://code.djangoproject.com/ticket/27058#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.9520203c28616f67eb88a5430a96bb20%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to