launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #11767
[Merge] lp:~lifeless/python-oops-tools/bug-1048470 into lp:python-oops-tools
Robert Collins has proposed merging lp:~lifeless/python-oops-tools/bug-1048470 into lp:python-oops-tools.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1048470 in python-oops-tools: "UnicodeEncodeError with non-ascii page ids"
https://bugs.launchpad.net/python-oops-tools/+bug/1048470
For more details, see:
https://code.launchpad.net/~lifeless/python-oops-tools/bug-1048470/+merge/123672
Further breakage existed. Fixed.
--
https://code.launchpad.net/~lifeless/python-oops-tools/bug-1048470/+merge/123672
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~lifeless/python-oops-tools/bug-1048470 into lp:python-oops-tools.
=== modified file 'src/oopstools/oops/dbsummaries.py'
--- src/oopstools/oops/dbsummaries.py 2012-09-10 05:24:03 +0000
+++ src/oopstools/oops/dbsummaries.py 2012-09-11 02:11:18 +0000
@@ -138,6 +138,7 @@
data['escaped_url'] = _escape(data['url'])
data['errors'] = data['errors'].split(',')
data['errors'].sort()
+ data['url'] = data['url'].encode('utf8')
return res
@Lazy
@@ -156,7 +157,8 @@
def renderTXT(self, fp):
"""Render this group in plain text."""
- fp.write('%4d %s: %s\n' % (self.count, self.etype, self.evalue))
+ fp.write('%4d %s: %s\n' % (
+ self.count, self.etype.encode('utf8'), self.evalue.encode('utf8')))
if self.bug:
fp.write(' Bug: https://launchpad.net/bugs/%s\n' % self.bug)
http_methods = self.formatted_http_method_count()
@@ -468,7 +470,8 @@
fp.write('=== Top %d %s ===\n\n' % (self.max_count, self.title))
for value, oopsids, pageid in self.top_errors:
formatted_value = self.field_format % value
- fp.write('%s %-14s %s\n' % (formatted_value, oopsids[0], pageid))
+ fp.write('%s %-14s %s\n' % (formatted_value,
+ oopsids[0].encode('utf8'), pageid.encode('utf8')))
fp.write('\n\n')
=== modified file 'src/oopstools/oops/test/test_dbsummaries.py'
--- src/oopstools/oops/test/test_dbsummaries.py 2012-09-10 05:24:03 +0000
+++ src/oopstools/oops/test/test_dbsummaries.py 2012-09-11 02:11:18 +0000
@@ -18,6 +18,7 @@
datetime,
)
from cStringIO import StringIO
+import uuid
from pytz import utc
from testtools import TestCase
@@ -31,7 +32,7 @@
def _createOops(self):
python_oops = {
- 'id': 'OOPS-1234S101',
+ 'id': uuid.uuid4().get_hex(),
'reporter': 'edge',
'type': 'Exception',
'value': u'a unicode char (\xa7)',
@@ -39,7 +40,7 @@
'topic': u'more unicode \xa7',
}
ignored = parsed_oops_to_model_oops(
- python_oops, 'test_unicode_handling')
+ python_oops, str(self.id()))
def setUp(self):
super(TestWebAppErrorSummary, self).setUp()
@@ -55,3 +56,11 @@
self.summary.renderHTML(fp)
self.assertThat(fp.getvalue(), Contains('a unicode char (\xc2\xa7)'))
self.assertThat(fp.getvalue(), Contains('more unicode \xc2\xa7'))
+
+ def test_renderTXT_with_unicode_data(self):
+ # Summarising an oops with a unicode exception value should output
+ # a UTF-8 encoded text representation.
+ fp = StringIO()
+ self.summary.renderTXT(fp)
+ self.assertThat(fp.getvalue(), Contains('a unicode char (\xc2\xa7)'))
+ self.assertThat(fp.getvalue(), Contains('more unicode \xc2\xa7'))