#13222: unexpected HttpResponse iteration behavior
-------------------------------------+-------------------------------------
     Reporter:  teepark              |                    Owner:  aaugustin
         Type:  Bug                  |                   Status:  new
    Component:  HTTP handling        |                  Version:  1.3-rc1
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Ready for
    Has patch:  1                    |  checkin
  Needs tests:  0                    |      Needs documentation:  0
Easy pickings:  0                    |  Patch needs improvement:  0
                                     |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by teepark):

 `@content.setter` actually supports any iterable type, and dictionaries
 and set iterators (and perhaps others) will raise if their original object
 is modified since the iterator's creation.

 {{{
 >>> s = set([1,2,3])
 >>> i = iter(s)
 >>> s.add(4)
 >>> list(i)
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
 RuntimeError: Set changed size during iteration
 }}}

 There's not really a good reason to use either of those types as
 `HttpResponse.content`, but `_content` becomes the provided object so long
 as it `hasattr("__iter__")`, so this implementation does also create new
 limitations on what is an acceptable `content`.

 It's my general feeling that separate iterators for separate `__iter__`
 invocations is a more robust approach because of this kind of issue, but
 this patch is far and away better than the current behavior.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/13222#comment:23>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to