I wrote a patch for #16494 [1] that could use some a few more eyes. In short, the issue here is that the existing code for setting the content of an HTTPResponse behaves inconsistently when given non-strings. Setting content during __init__ behaves differently for iterators than setting it later via the content property. If a non-string, non-iterator is set for content, the code eventually throws an error during string operations. If content is an iterator, it is iterated over and (crucially) the content is converted to a string.
My initial response was to fix the logic error for non-strings and return an explicit error stating that this function requires a string for content. However, since the existing iterator code does convert to a string, the most consistent thing we can do here seems to be converting everything (including non-iterators) right before output. I added some test cases and cleaned the code up a bit. I believe sure this solution is backwards compatible (we're adding the string conversion, something that shouldn't have been possible before), but I'd like input from some other people. -Paul [1] https://code.djangoproject.com/ticket/16494 -- You received this message because you are subscribed to the Google Groups "Django developers" 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 this group at http://groups.google.com/group/django-developers?hl=en.
