Changes between Initial Version and Version 2 of Ticket #4990


Ignore:
Timestamp:
Aug 11, 2007, 6:34:36 AM (17 years ago)
Author:
Malcolm Tredinnick
Comment:

This patch doesn't look correct. The Unicode and str representations would only be identical if all the data was guaranteed to be ASCII and that's not true for the "content" attribute. Plus there should at least be a call to unicode() in there somewhere so that the right type is returned (rather than assuming Python's C layer will correct the problem, which is kind of accidental).

Thinking about the actual problem report, the whole approach looks like it's covering over a different problem: what should the encoding of the content be and how to represent that correctly as UTF-8 (in __str__) or as Unicode (which is what the __unicode__ method must return)?

More thinking is required here. No question that something is going wrong, but I need to trace through our encoding assumptions so that we can lay down the right rules for how to treat the content. It's not immediately clear that a __unicode__ method is needed, since an HttpResponse is always sent as a sequence of bytes.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #4990

    • Property Triage Stage UnreviewedAccepted
    • Property Summary HttpResponse.__unicode__Problems in HttpResponse __str__ method.
    • Property Has patch unset
  • Ticket #4990 – Description

    initial v2  
    22
    33I got this exception:
     4{{{
    45UnicodeEncodeError at /.../
    56'ascii' codec can't encode character u'\xe4' in position 33614: ordinal not in range(128)
     
    2122
    2223  40.         s = unicode(str(s), encoding, errors) ...
     24}}}
    2325
    24 s is a django.http.HttpResponseServerError object.
     26s is a django.http.!HttpResponseServerError object.
    2527
    26 This patch gives HttpResponse a __unicode__ method.
     28This patch gives !HttpResponse a {{{__unicode__}}} method.
    2729       
    2830
Back to Top