Merge lp:~mterry/duplicity/more-decode-issues into lp:~duplicity-team/duplicity/0.8-series

Proposed by Michael Terry
Status: Merged
Merged at revision: 1264
Proposed branch: lp:~mterry/duplicity/more-decode-issues
Merge into: lp:~duplicity-team/duplicity/0.8-series
Diff against target: 87 lines (+9/-8)
3 files modified
bin/duplicity (+5/-5)
duplicity/dup_time.py (+3/-2)
duplicity/util.py (+1/-1)
To merge this branch: bzr merge lp:~mterry/duplicity/more-decode-issues
Reviewer Review Type Date Requested Status
duplicity-team Pending
Review via email: mp+330299@code.launchpad.net

Description of the change

Here's some fixes for another couple UnicodeDecodeErrors.

The duplicity/dup_time.py fixes when a user passes a utf8 date string (or a string with bogus utf8 characters, but they have to really try to do that). This is bug 1334436.

The bin/duplicity change from str(e) to util.uexc(e) fixes bug 1324188.

The rest of the changes (util.exception_traceback and bin/duplicity changes to use it) are to make the printing of exceptions prettier. Without this, if you see a French exception, you see "accept\xe9es" instead of "acceptées".

You can test all of these changes in one simple line:

LANGUAGE=fr duplicity remove-older-than $'accept\xffées'

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 'bin/duplicity'
2--- bin/duplicity 2017-08-15 20:14:46 +0000
3+++ bin/duplicity 2017-09-06 16:02:14 +0000
4@@ -1691,7 +1691,7 @@
5 # default. But do with sufficient verbosity.
6 util.release_lockfile()
7 log.Info(_("GPG error detail: %s")
8- % (u''.join(traceback.format_exception(*sys.exc_info()))))
9+ % util.exception_traceback())
10 log.FatalError(u"%s: %s" % (e.__class__.__name__, e.args[0]),
11 log.ErrorCode.gpg_failed,
12 e.__class__.__name__)
13@@ -1701,7 +1701,7 @@
14 # For user errors, don't show an ugly stack trace by
15 # default. But do with sufficient verbosity.
16 log.Info(_("User error detail: %s")
17- % (u''.join(traceback.format_exception(*sys.exc_info()))))
18+ % util.exception_traceback())
19 log.FatalError(u"%s: %s" % (e.__class__.__name__, util.uexc(e)),
20 log.ErrorCode.user_error,
21 e.__class__.__name__)
22@@ -1711,19 +1711,19 @@
23 # For backend errors, don't show an ugly stack trace by
24 # default. But do with sufficient verbosity.
25 log.Info(_("Backend error detail: %s")
26- % (u''.join(traceback.format_exception(*sys.exc_info()))))
27+ % util.exception_traceback())
28 log.FatalError(u"%s: %s" % (e.__class__.__name__, util.uexc(e)),
29 log.ErrorCode.user_error,
30 e.__class__.__name__)
31
32 except Exception as e:
33 util.release_lockfile()
34- if "Forced assertion for testing" in str(e):
35+ if "Forced assertion for testing" in util.uexc(e):
36 log.FatalError(u"%s: %s" % (e.__class__.__name__, util.uexc(e)),
37 log.ErrorCode.exception,
38 e.__class__.__name__)
39 else:
40 # Traceback and that mess
41- log.FatalError(u''.join(traceback.format_exception(*sys.exc_info())),
42+ log.FatalError(util.exception_traceback(),
43 log.ErrorCode.exception,
44 e.__class__.__name__)
45
46=== modified file 'duplicity/dup_time.py'
47--- duplicity/dup_time.py 2017-02-20 00:05:17 +0000
48+++ duplicity/dup_time.py 2017-09-06 16:02:14 +0000
49@@ -29,6 +29,7 @@
50 import calendar
51 import sys
52 from duplicity import globals
53+from duplicity import util
54
55 # For type testing against both int and long types that works in python 2/3
56 if sys.version_info < (3,):
57@@ -199,7 +200,7 @@
58 def intstringtoseconds(interval_string):
59 """Convert a string expressing an interval (e.g. "4D2s") to seconds"""
60 def error():
61- raise TimeException(bad_interval_string % interval_string)
62+ raise TimeException(bad_interval_string % util.escape(interval_string))
63
64 if len(interval_string) < 2:
65 error()
66@@ -282,7 +283,7 @@
67 return override_curtime
68
69 def error():
70- raise TimeException(bad_time_string % timestr)
71+ raise TimeException(bad_time_string % util.escape(timestr))
72
73 # Test for straight integer
74 if _integer_regexp.search(timestr):
75
76=== modified file 'duplicity/util.py'
77--- duplicity/util.py 2017-07-11 14:55:38 +0000
78+++ duplicity/util.py 2017-09-06 16:02:14 +0000
79@@ -48,7 +48,7 @@
80 msg = "Traceback (innermost last):\n"
81 msg = msg + "%-20s %s" % (string.join(lines[:-1], ""), lines[-1])
82
83- return uexc(msg)
84+ return msg.decode('unicode-escape', 'replace')
85
86
87 def escape(string):

Subscribers

People subscribed via source and target branches