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
=== modified file 'duplicity/patchdir.py'
--- duplicity/patchdir.py 2013-09-19 00:26:01 +0000
+++ duplicity/patchdir.py 2013-11-16 03:48:51 +0000
@@ -498,13 +498,14 @@
498 """498 """
499 collated = collate_iters( iter_list )499 collated = collate_iters( iter_list )
500 for patch_seq in collated:500 for patch_seq in collated:
501 normalized = normalize_ps(patch_seq)
501 try:502 try:
502 final_ropath = patch_seq2ropath(normalize_ps(patch_seq))503 final_ropath = patch_seq2ropath(normalized)
503 if final_ropath.exists():504 if final_ropath.exists():
504 # otherwise final patch was delete505 # otherwise final patch was delete
505 yield final_ropath506 yield final_ropath
506 except Exception, e:507 except Exception, e:
507 filename = patch_seq[-1].get_ropath().get_relative_path()508 filename = normalized[-1].get_ropath().get_relative_path()
508 log.Warn(_("Error '%s' patching %s") % 509 log.Warn(_("Error '%s' patching %s") %
509 (str(e), filename),510 (str(e), filename),
510 log.WarningCode.cannot_process,511 log.WarningCode.cannot_process,

Subscribers

People subscribed via source and target branches

to all changes: