Merge lp:~wgrant/python-oops-tools/fix-str-coerce-list into lp:python-oops-tools

Proposed by William Grant on 2016-12-15
Status: Merged
Approved by: William Grant on 2016-12-15
Approved revision: 56
Merged at revision: 56
Proposed branch: lp:~wgrant/python-oops-tools/fix-str-coerce-list
Merge into: lp:python-oops-tools
Diff against target: 32 lines (+5/-2)
2 files modified
src/oopstools/oops/models.py (+4/-1)
src/oopstools/oops/test/test_dboopsloader.py (+1/-1)
To merge this branch: bzr merge lp:~wgrant/python-oops-tools/fix-str-coerce-list
Reviewer Review Type Date Requested Status
Colin Watson 2016-12-15 Approve on 2016-12-15
Review via email: mp+313339@code.launchpad.net

Commit message

Fix statement string coercion to cope with non-tuple actions.

Description of the change

Fix statement string coercion to cope with non-tuple actions.

We tend to encode actions as lists, not tuples, which causes the
coercion to fail when it tries to concatenate a list and a tuple.

This hit SSO when it started sending statements as binary rather than
string.

To post a comment you must log in.
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/oopstools/oops/models.py'
2--- src/oopstools/oops/models.py 2013-02-25 21:41:12 +0000
3+++ src/oopstools/oops/models.py 2016-12-15 10:20:18 +0000
4@@ -387,11 +387,14 @@
5 else:
6 filler = (0, 0, 'unknown', 'unknown', 'unknown')
7 for row, action in enumerate(statements):
8+ # action is expected to be a tuple, but most formats encode it as a
9+ # list.
10+ action = tuple(action)
11 # Must have a string as the statement
12 if len(action) > 3 and not isinstance(action[3], basestring):
13 action = action[:3] + (str(action[3]),) + action[4:]
14 # Must have length == 5
15- statements[row] = tuple(action[:5]) + filler[len(action):]
16+ statements[row] = action[:5] + filler[len(action):]
17 duration = oops.get('duration')
18 if duration is not None:
19 total_time = int(duration * 1000)
20
21=== modified file 'src/oopstools/oops/test/test_dboopsloader.py'
22--- src/oopstools/oops/test/test_dboopsloader.py 2013-02-25 21:41:12 +0000
23+++ src/oopstools/oops/test/test_dboopsloader.py 2016-12-15 10:20:18 +0000
24@@ -238,7 +238,7 @@
25 report = {
26 'id': 'dict-statement',
27 'timeline': [
28- (1, 2, 'foo', {}, 'baz'),
29+ [1, 2, 'foo', {}, 'baz'],
30 ],
31 }
32 oops = parsed_oops_to_model_oops(report, 'dict-statement')

Subscribers

People subscribed via source and target branches

to all changes: