Message ID | 20110210184505.GA17251@zap |
---|---|
State | Rejected |
Headers | show |
Dirk,
> Otherwise there will be a UnicodeDecodeError.
Where are you getting this UnicodeDecodeError? With 7fd7d0bbe reverted, I see
all the testcases pass.
Cheers,
Jeremy
On Fri, Feb 11, 2011 at 07:57:26AM +0800, Jeremy Kerr wrote: > Dirk, > > > Otherwise there will be a UnicodeDecodeError. > > Where are you getting this UnicodeDecodeError? With 7fd7d0bbe reverted, I see > all the testcases pass. Hm, maybe this is a Python bug (Python-2.6.5). Seemed a bit strange anyway as the doc explicitly allows to pass in unicode. I get a couple of these (all errors attached): ====================================================================== ERROR: testCommentContent (patchwork.tests.patchparser.UTF8InlinePatchTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/srv/patchwork/apps/patchwork/tests/patchparser.py", line 85, in setUp (self.patch, self.comment) = find_content(self.project, email) File "/srv/patchwork/apps/patchwork/bin/parsemail.py", line 166, in find_content payload = unicode(payload, charset) UnicodeDecodeError: 'utf8' codec can't decode bytes in position 146-148: invalid data ======================================================================
On Fri, Feb 11, 2011 at 10:41:54AM +0100, Dirk Wallenstein wrote: > On Fri, Feb 11, 2011 at 07:57:26AM +0800, Jeremy Kerr wrote: > > Dirk, > > > > > Otherwise there will be a UnicodeDecodeError. > > > > Where are you getting this UnicodeDecodeError? With 7fd7d0bbe reverted, I see > > all the testcases pass. > > Hm, maybe this is a Python bug (Python-2.6.5). Seemed a bit strange > anyway as the doc explicitly allows to pass in unicode. I get a couple > of these (all errors attached): > > ====================================================================== > ERROR: testCommentContent (patchwork.tests.patchparser.UTF8InlinePatchTest) > ---------------------------------------------------------------------- > Traceback (most recent call last): > File "/srv/patchwork/apps/patchwork/tests/patchparser.py", line 85, in setUp > (self.patch, self.comment) = find_content(self.project, email) > File "/srv/patchwork/apps/patchwork/bin/parsemail.py", line 166, in find_content > payload = unicode(payload, charset) > UnicodeDecodeError: 'utf8' codec can't decode bytes in position 146-148: invalid data > > ====================================================================== Yap, gone with Python-2.6.6
diff --git a/apps/patchwork/tests/patchparser.py b/apps/patchwork/tests/patchparser.py index ff0025a..357ffc1 100644 --- a/apps/patchwork/tests/patchparser.py +++ b/apps/patchwork/tests/patchparser.py @@ -80,7 +80,10 @@ class UTF8InlinePatchTest(InlinePatchTest): def setUp(self): self.orig_patch = read_patch(self.patch_filename, self.patch_encoding) - email = create_email(self.test_comment + '\n' + self.orig_patch, + patch_content = self.test_comment + '\n' + self.orig_patch + if isinstance(patch_content, unicode): + patch_content = patch_content.encode(self.patch_encoding) + email = create_email(patch_content, content_encoding = self.patch_encoding) (self.patch, self.comment) = find_content(self.project, email)