Merge lp:~mterry/duplicity/utf8-po into lp:duplicity/0.6

Proposed by Michael Terry
Status: Merged
Merged at revision: 863
Proposed branch: lp:~mterry/duplicity/utf8-po
Merge into: lp:duplicity/0.6
Diff against target: 92 lines (+43/-4)
5 files modified
bin/duplicity (+1/-1)
bin/rdiffdir (+1/-1)
duplicity/__init__.py (+1/-1)
testing/manual/config.py.tmpl (+1/-1)
testing/tests/unicode.py (+39/-0)
To merge this branch: bzr merge lp:~mterry/duplicity/utf8-po
Reviewer Review Type Date Requested Status
duplicity-team Pending
Review via email: mp+124209@code.launchpad.net

Description of the change

For some crazy reason, the gettext module defaults to giving you strings in whatever charset the po file happened to define. Which means you never know what string of bytes you're going to get.

This module makes sure we always get utf-8 byte strings. So we're at least predictable and reduces one source of UnicodeDecodeErrors (like in bug 989496)

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 2012-02-29 13:35:03 +0000
3+++ bin/duplicity 2012-09-13 14:12:28 +0000
4@@ -35,7 +35,7 @@
5 sys.path.insert(0, os.path.abspath(os.path.join(pwd, "../.")))
6
7 import gettext
8-gettext.install('duplicity')
9+gettext.install('duplicity', codeset='utf8')
10
11 from duplicity import log
12 log.setup()
13
14=== modified file 'bin/rdiffdir'
15--- bin/rdiffdir 2011-11-07 15:08:24 +0000
16+++ bin/rdiffdir 2012-09-13 14:12:28 +0000
17@@ -28,7 +28,7 @@
18 import sys, getopt, gzip, os
19
20 import gettext
21-gettext.install('duplicity')
22+gettext.install('duplicity', codeset='utf8')
23
24 from duplicity import diffdir
25 from duplicity import patchdir
26
27=== modified file 'duplicity/__init__.py'
28--- duplicity/__init__.py 2009-04-21 17:21:06 +0000
29+++ duplicity/__init__.py 2012-09-13 14:12:28 +0000
30@@ -20,4 +20,4 @@
31 # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32
33 import gettext
34-gettext.install('duplicity')
35+gettext.install('duplicity', codeset='utf8')
36
37=== modified file 'testing/manual/config.py.tmpl'
38--- testing/manual/config.py.tmpl 2011-11-17 15:59:54 +0000
39+++ testing/manual/config.py.tmpl 2012-09-13 14:12:28 +0000
40@@ -25,7 +25,7 @@
41 sys.path.insert(0, newpath)
42
43 import gettext
44-gettext.install('duplicity')
45+gettext.install('duplicity', codeset='utf8')
46
47 from duplicity import globals
48 from duplicity import log
49
50=== added file 'testing/tests/unicode.py'
51--- testing/tests/unicode.py 1970-01-01 00:00:00 +0000
52+++ testing/tests/unicode.py 2012-09-13 14:12:28 +0000
53@@ -0,0 +1,39 @@
54+# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
55+#
56+# Copyright 2012 Canonical Ltd
57+#
58+# This file is part of duplicity.
59+#
60+# Duplicity is free software; you can redistribute it and/or modify it
61+# under the terms of the GNU General Public License as published by the
62+# Free Software Foundation; either version 2 of the License, or (at your
63+# option) any later version.
64+#
65+# Duplicity is distributed in the hope that it will be useful, but
66+# WITHOUT ANY WARRANTY; without even the implied warranty of
67+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
68+# General Public License for more details.
69+#
70+# You should have received a copy of the GNU General Public License
71+# along with duplicity; if not, write to the Free Software Foundation,
72+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
73+
74+import sys
75+import unittest
76+from mock import patch
77+
78+
79+class UTF8Test(unittest.TestCase):
80+
81+ def setUp(self):
82+ if 'duplicity' in sys.modules:
83+ del(sys.modules["duplicity"])
84+
85+ @patch('gettext.install')
86+ def test_module_install(self, inst_mock):
87+ """Make sure we convert po files to utf8"""
88+ import duplicity
89+ inst_mock.assert_called_once_with('duplicity', codeset='utf8')
90+
91+if __name__ == "__main__":
92+ unittest.main()

Subscribers

People subscribed via source and target branches

to all changes: