Merge lp:~lifeless/python-oops-tools/bug-1048470 into lp:python-oops-tools

Proposed by Robert Collins on 2012-09-11
Status: Merged
Approved by: Robert Collins on 2012-09-11
Approved revision: 40
Merged at revision: 40
Proposed branch: lp:~lifeless/python-oops-tools/bug-1048470
Merge into: lp:python-oops-tools
Diff against target: 73 lines (+16/-4)
2 files modified
src/oopstools/oops/dbsummaries.py (+5/-2)
src/oopstools/oops/test/test_dbsummaries.py (+11/-2)
To merge this branch: bzr merge lp:~lifeless/python-oops-tools/bug-1048470
Reviewer Review Type Date Requested Status
William Grant code 2012-09-11 Approve on 2012-09-11
Review via email: mp+123672@code.launchpad.net

Commit Message

Fix TXT reports for unicode pageids as well.

Description of the Change

Further breakage existed. Fixed.

To post a comment you must log in.
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/oopstools/oops/dbsummaries.py'
2--- src/oopstools/oops/dbsummaries.py 2012-09-10 05:24:03 +0000
3+++ src/oopstools/oops/dbsummaries.py 2012-09-11 02:11:18 +0000
4@@ -138,6 +138,7 @@
5 data['escaped_url'] = _escape(data['url'])
6 data['errors'] = data['errors'].split(',')
7 data['errors'].sort()
8+ data['url'] = data['url'].encode('utf8')
9 return res
10
11 @Lazy
12@@ -156,7 +157,8 @@
13
14 def renderTXT(self, fp):
15 """Render this group in plain text."""
16- fp.write('%4d %s: %s\n' % (self.count, self.etype, self.evalue))
17+ fp.write('%4d %s: %s\n' % (
18+ self.count, self.etype.encode('utf8'), self.evalue.encode('utf8')))
19 if self.bug:
20 fp.write(' Bug: https://launchpad.net/bugs/%s\n' % self.bug)
21 http_methods = self.formatted_http_method_count()
22@@ -468,7 +470,8 @@
23 fp.write('=== Top %d %s ===\n\n' % (self.max_count, self.title))
24 for value, oopsids, pageid in self.top_errors:
25 formatted_value = self.field_format % value
26- fp.write('%s %-14s %s\n' % (formatted_value, oopsids[0], pageid))
27+ fp.write('%s %-14s %s\n' % (formatted_value,
28+ oopsids[0].encode('utf8'), pageid.encode('utf8')))
29 fp.write('\n\n')
30
31
32
33=== modified file 'src/oopstools/oops/test/test_dbsummaries.py'
34--- src/oopstools/oops/test/test_dbsummaries.py 2012-09-10 05:24:03 +0000
35+++ src/oopstools/oops/test/test_dbsummaries.py 2012-09-11 02:11:18 +0000
36@@ -18,6 +18,7 @@
37 datetime,
38 )
39 from cStringIO import StringIO
40+import uuid
41
42 from pytz import utc
43 from testtools import TestCase
44@@ -31,7 +32,7 @@
45
46 def _createOops(self):
47 python_oops = {
48- 'id': 'OOPS-1234S101',
49+ 'id': uuid.uuid4().get_hex(),
50 'reporter': 'edge',
51 'type': 'Exception',
52 'value': u'a unicode char (\xa7)',
53@@ -39,7 +40,7 @@
54 'topic': u'more unicode \xa7',
55 }
56 ignored = parsed_oops_to_model_oops(
57- python_oops, 'test_unicode_handling')
58+ python_oops, str(self.id()))
59
60 def setUp(self):
61 super(TestWebAppErrorSummary, self).setUp()
62@@ -55,3 +56,11 @@
63 self.summary.renderHTML(fp)
64 self.assertThat(fp.getvalue(), Contains('a unicode char (\xc2\xa7)'))
65 self.assertThat(fp.getvalue(), Contains('more unicode \xc2\xa7'))
66+
67+ def test_renderTXT_with_unicode_data(self):
68+ # Summarising an oops with a unicode exception value should output
69+ # a UTF-8 encoded text representation.
70+ fp = StringIO()
71+ self.summary.renderTXT(fp)
72+ self.assertThat(fp.getvalue(), Contains('a unicode char (\xc2\xa7)'))
73+ self.assertThat(fp.getvalue(), Contains('more unicode \xc2\xa7'))

Subscribers

People subscribed via source and target branches

to all changes: