Merge lp:~mterry/duplicity/normalize-before-using into lp:duplicity/0.6

Proposed by Michael Terry
Status: Merged
Merged at revision: 936
Proposed branch: lp:~mterry/duplicity/normalize-before-using
Merge into: lp:duplicity/0.6
Diff against target: 20 lines (+3/-2)
1 file modified
duplicity/patchdir.py (+3/-2)
To merge this branch: bzr merge lp:~mterry/duplicity/normalize-before-using
Reviewer Review Type Date Requested Status
duplicity-team Pending
Review via email: mp+195463@code.launchpad.net

Description of the change

Avoid throwing an exception due to a None element in a patch sequence.

None elements in a (non-normalized) patch sequence are perfectly normal. With the current code in the patched function, it is certainly possible to hit a crash due a None. See http://lists.nongnu.org/archive/html/duplicity-talk/2013-11/msg00005.html

This branch fixes that by normalizing the sequence before using it in the logging code. It's acceptable to bring the normalize_ps() call outside the try/except block because normalize_ps is not expected to throw. It's relatively simple and doesn't really use its objects besides checking if they are None.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'duplicity/patchdir.py'
2--- duplicity/patchdir.py 2013-09-19 00:26:01 +0000
3+++ duplicity/patchdir.py 2013-11-16 03:48:51 +0000
4@@ -498,13 +498,14 @@
5 """
6 collated = collate_iters( iter_list )
7 for patch_seq in collated:
8+ normalized = normalize_ps(patch_seq)
9 try:
10- final_ropath = patch_seq2ropath(normalize_ps(patch_seq))
11+ final_ropath = patch_seq2ropath(normalized)
12 if final_ropath.exists():
13 # otherwise final patch was delete
14 yield final_ropath
15 except Exception, e:
16- filename = patch_seq[-1].get_ropath().get_relative_path()
17+ filename = normalized[-1].get_ropath().get_relative_path()
18 log.Warn(_("Error '%s' patching %s") %
19 (str(e), filename),
20 log.WarningCode.cannot_process,

Subscribers

People subscribed via source and target branches

to all changes: