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

2008-01-08 Thread Malcolm Tredinnick
On Tue, 2008-01-08 at 22:45 -0600, Gary Wilson Jr. wrote: > 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: >

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.csrf.middleware.CsrfMiddleware.process_response: >>

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

2008-01-08 Thread Malcolm Tredinnick
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.csrf.middleware.CsrfMiddleware.process_response: > > def process_response(self, request,

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 bytestring. I'm playing with a

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

2008-01-07 Thread Malcolm Tredinnick
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 > >> bytestring. > >> I'm playing with a response middleware doing something

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' % text, response.content) >> >> which raises

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

2008-01-06 Thread Malcolm Tredinnick
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' % text, response.content) > > which raises a UnicodeDecodeError if

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