Merge lp:~rye/python-oops-datedir-repo/empty-oops into lp:python-oops-datedir-repo

Proposed by Roman Yepishev
Status: Merged
Approved by: Robert Collins
Approved revision: 31
Merged at revision: 30
Proposed branch: lp:~rye/python-oops-datedir-repo/empty-oops
Merge into: lp:python-oops-datedir-repo
Diff against target: 28 lines (+10/-0)
2 files modified
oops_datedir_repo/serializer.py (+5/-0)
oops_datedir_repo/tests/test_serializer.py (+5/-0)
To merge this branch: bzr merge lp:~rye/python-oops-datedir-repo/empty-oops
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Review via email: mp+83378@code.launchpad.net

Description of the change

This checks for length of the oops content before sending it to serializers.
OOPSes of 0 sizes signal about the problem with serializer, but they should not prevent oops loader from working properly.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

This looks fine modulo pep8 cosmetic stuff (trailing line in file, spurious VWS in the code, and also a missing NEWS entry. I'll add those and land it.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'oops_datedir_repo/serializer.py'
--- oops_datedir_repo/serializer.py 2011-11-11 04:21:05 +0000
+++ oops_datedir_repo/serializer.py 2011-11-25 09:30:28 +0000
@@ -48,6 +48,11 @@
48 """48 """
49 # Deal with no-rewindable file pointers.49 # Deal with no-rewindable file pointers.
50 content = fp.read()50 content = fp.read()
51
52 if len(content) == 0:
53 # This OOPS has no content
54 raise IOError("Empty OOPS Report")
55
51 try:56 try:
52 return serializer_bson.read(StringIO(content))57 return serializer_bson.read(StringIO(content))
53 except KeyError:58 except KeyError:
5459
=== modified file 'oops_datedir_repo/tests/test_serializer.py'
--- oops_datedir_repo/tests/test_serializer.py 2011-11-11 04:48:09 +0000
+++ oops_datedir_repo/tests/test_serializer.py 2011-11-25 09:30:28 +0000
@@ -67,3 +67,8 @@
67 source_file.write(dumps(dict(self.source_dict)))67 source_file.write(dumps(dict(self.source_dict)))
68 source_file.seek(0)68 source_file.seek(0)
69 self.assertEqual(self.expected_dict, read(source_file))69 self.assertEqual(self.expected_dict, read(source_file))
70
71 def test_ioerror_on_empty_oops(self):
72 source_file = StringIO.StringIO()
73 self.assertRaises(IOError, read, source_file)
74

Subscribers

People subscribed via source and target branches

to all changes: