← Back to team overview

duplicity-team team mailing list archive

[Merge] lp:~mterry/duplicity/more-decode-issues into lp:duplicity

 

Michael Terry has proposed merging lp:~mterry/duplicity/more-decode-issues into lp:duplicity.

Requested reviews:
  duplicity-team (duplicity-team)
Related bugs:
  Bug #1324188 in Duplicity: "duplicity crashed with wrong parameters"
  https://bugs.launchpad.net/duplicity/+bug/1324188
  Bug #1334436 in Duplicity: "Backup fails"
  https://bugs.launchpad.net/duplicity/+bug/1334436

For more details, see:
https://code.launchpad.net/~mterry/duplicity/more-decode-issues/+merge/330299

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'
-- 
Your team duplicity-team is requested to review the proposed merge of lp:~mterry/duplicity/more-decode-issues into lp:duplicity.
=== modified file 'bin/duplicity'
--- bin/duplicity	2017-08-15 20:14:46 +0000
+++ bin/duplicity	2017-09-06 16:02:14 +0000
@@ -1691,7 +1691,7 @@
         # default. But do with sufficient verbosity.
         util.release_lockfile()
         log.Info(_("GPG error detail: %s")
-                 % (u''.join(traceback.format_exception(*sys.exc_info()))))
+                 % util.exception_traceback())
         log.FatalError(u"%s: %s" % (e.__class__.__name__, e.args[0]),
                        log.ErrorCode.gpg_failed,
                        e.__class__.__name__)
@@ -1701,7 +1701,7 @@
         # For user errors, don't show an ugly stack trace by
         # default. But do with sufficient verbosity.
         log.Info(_("User error detail: %s")
-                 % (u''.join(traceback.format_exception(*sys.exc_info()))))
+                 % util.exception_traceback())
         log.FatalError(u"%s: %s" % (e.__class__.__name__, util.uexc(e)),
                        log.ErrorCode.user_error,
                        e.__class__.__name__)
@@ -1711,19 +1711,19 @@
         # For backend errors, don't show an ugly stack trace by
         # default. But do with sufficient verbosity.
         log.Info(_("Backend error detail: %s")
-                 % (u''.join(traceback.format_exception(*sys.exc_info()))))
+                 % util.exception_traceback())
         log.FatalError(u"%s: %s" % (e.__class__.__name__, util.uexc(e)),
                        log.ErrorCode.user_error,
                        e.__class__.__name__)
 
     except Exception as e:
         util.release_lockfile()
-        if "Forced assertion for testing" in str(e):
+        if "Forced assertion for testing" in util.uexc(e):
             log.FatalError(u"%s: %s" % (e.__class__.__name__, util.uexc(e)),
                            log.ErrorCode.exception,
                            e.__class__.__name__)
         else:
             # Traceback and that mess
-            log.FatalError(u''.join(traceback.format_exception(*sys.exc_info())),
+            log.FatalError(util.exception_traceback(),
                            log.ErrorCode.exception,
                            e.__class__.__name__)

=== modified file 'duplicity/dup_time.py'
--- duplicity/dup_time.py	2017-02-20 00:05:17 +0000
+++ duplicity/dup_time.py	2017-09-06 16:02:14 +0000
@@ -29,6 +29,7 @@
 import calendar
 import sys
 from duplicity import globals
+from duplicity import util
 
 # For type testing against both int and long types that works in python 2/3
 if sys.version_info < (3,):
@@ -199,7 +200,7 @@
 def intstringtoseconds(interval_string):
     """Convert a string expressing an interval (e.g. "4D2s") to seconds"""
     def error():
-        raise TimeException(bad_interval_string % interval_string)
+        raise TimeException(bad_interval_string % util.escape(interval_string))
 
     if len(interval_string) < 2:
         error()
@@ -282,7 +283,7 @@
         return override_curtime
 
     def error():
-        raise TimeException(bad_time_string % timestr)
+        raise TimeException(bad_time_string % util.escape(timestr))
 
     # Test for straight integer
     if _integer_regexp.search(timestr):

=== modified file 'duplicity/util.py'
--- duplicity/util.py	2017-07-11 14:55:38 +0000
+++ duplicity/util.py	2017-09-06 16:02:14 +0000
@@ -48,7 +48,7 @@
     msg = "Traceback (innermost last):\n"
     msg = msg + "%-20s %s" % (string.join(lines[:-1], ""), lines[-1])
 
-    return uexc(msg)
+    return msg.decode('unicode-escape', 'replace')
 
 
 def escape(string):


Follow ups