From 24e0e1ff64b1bcaede0366f9c0765bc740754da8 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Wed, 23 Oct 2013 16:22:50 +0000 Subject: Fix app.status call in log_dict_diff This bug was triggered by the fix to CachedRepo.resolve_ref and without this fix, the resolve_ref fix will break the test suite. The bug is that log_dict_diff calls the status method with an msg keyword argument that may contain percentage characters. status interprets the value of msg as a format string, and the percentage characters trigger formatting to happen. The fix for that is to not interpolate the value of key and dictA[key] and dictB[key] into msg before calling status, but letting status do that. Thus the msg values are changed to reference %(key)s instead and passing in a value for key as a separate argument. Ditto for dictA[key] and dictB[key]. --- morphlib/util.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/morphlib/util.py b/morphlib/util.py index 3d9232d4..53a9e283 100644 --- a/morphlib/util.py +++ b/morphlib/util.py @@ -177,7 +177,8 @@ def log_dict_diff(app, cur, pre): # pragma: no cover dictB = pre for key in dictA.keys(): if key not in dictB: - app.status(msg="New environment: %s = %s" % (key, dictA[key]), + app.status(msg="New environment: %(key)s = %(value)s", + key=key, value=dictA[key], chatty=True) elif dictA[key] != dictB[key]: app.status(msg= \ @@ -185,7 +186,8 @@ def log_dict_diff(app, cur, pre): # pragma: no cover % {"key": key, "valA": dictA[key], "valB": dictB[key]}) for key in dictB.keys(): if key not in dictA: - app.status(msg="Environment removed: %s = %s" % (key, dictB[key])) + app.status(msg="Environment removed: %(key)s = %(value)s", + key=key, value=dictB[key]) # This acquired from rdiff-backup which is GPLv2+ and a patch from 2011 -- cgit v1.2.1