Re: using re.sub with unicode string in response middleware

2008-01-08 Thread Gary Wilson Jr.
Malcolm Tredinnick wrote: > Hey Gary, > > On Tue, 2008-01-08 at 00:35 -0600, Gary Wilson Jr. wrote: > [...] >> So, looking at a couple places in Django trunk where response.content is >> used, >> these look like bugs: >> >> >> django.contrib

Re: using re.sub with unicode string in response middleware

2008-01-07 Thread Gary Wilson Jr.
Malcolm Tredinnick wrote: > On Mon, 2008-01-07 at 18:28 -0600, Gary Wilson Jr. wrote: >> Malcolm Tredinnick wrote: >>> On Sun, 2008-01-06 at 15:25 -0600, Gary Wilson Jr. wrote: >>>> It appears that at this point, response.content is a utf8-encoded >>&g

Re: using re.sub with unicode string in response middleware

2008-01-07 Thread Gary Wilson Jr.
Malcolm Tredinnick wrote: > On Sun, 2008-01-06 at 15:25 -0600, Gary Wilson Jr. wrote: >> It appears that at this point, response.content is a utf8-encoded bytestring. >> I'm playing with a response middleware doing something like: >> >> MY_RE.sub(u'%s' %

using re.sub with unicode string in response middleware

2008-01-06 Thread Gary Wilson Jr.
It appears that at this point, response.content is a utf8-encoded bytestring. I'm playing with a response middleware doing something like: MY_RE.sub(u'%s' % text, response.content) which raises a UnicodeDecodeError if response.content contains non-ascii. I understand that the strings need to be