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
1=== modified file 'oops_datedir_repo/serializer.py'
2--- oops_datedir_repo/serializer.py 2011-11-11 04:21:05 +0000
3+++ oops_datedir_repo/serializer.py 2011-11-25 09:30:28 +0000
4@@ -48,6 +48,11 @@
5 """
6 # Deal with no-rewindable file pointers.
7 content = fp.read()
8+
9+ if len(content) == 0:
10+ # This OOPS has no content
11+ raise IOError("Empty OOPS Report")
12+
13 try:
14 return serializer_bson.read(StringIO(content))
15 except KeyError:
16
17=== modified file 'oops_datedir_repo/tests/test_serializer.py'
18--- oops_datedir_repo/tests/test_serializer.py 2011-11-11 04:48:09 +0000
19+++ oops_datedir_repo/tests/test_serializer.py 2011-11-25 09:30:28 +0000
20@@ -67,3 +67,8 @@
21 source_file.write(dumps(dict(self.source_dict)))
22 source_file.seek(0)
23 self.assertEqual(self.expected_dict, read(source_file))
24+
25+ def test_ioerror_on_empty_oops(self):
26+ source_file = StringIO.StringIO()
27+ self.assertRaises(IOError, read, source_file)
28+

Subscribers

People subscribed via source and target branches

to all changes: