Rev 2274: ``GPGStrategy.sign()`` will now raise ``BzrBadParameterUnicode`` if in http://bzr.arbash-meinel.com/branches/bzr/0.15-dev/gpg-8-bit-only
John Arbash Meinel
john at arbash-meinel.com
Thu Feb 8 16:28:37 GMT 2007
At http://bzr.arbash-meinel.com/branches/bzr/0.15-dev/gpg-8-bit-only
------------------------------------------------------------
revno: 2274
revision-id: john at arbash-meinel.com-20070208162805-dcqiqrwjh9a5lo7n
parent: pqm at pqm.ubuntu.com-20070208031033-2ab8a0b14b6eaaba
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: gpg-8-bit-only
timestamp: Thu 2007-02-08 10:28:05 -0600
message:
``GPGStrategy.sign()`` will now raise ``BzrBadParameterUnicode`` if
you pass a Unicode string rather than an 8-bit string. It doesn't
make sense to sign a Unicode string, and it turns out that some
versions of python will write out the raw Unicode bytes rather than
encoding automatically. So fail and make callers do the right thing.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/gpg.py gpg.py-20051017065112-8654536d415dacc6
bzrlib/tests/test_gpg.py testgpg.py-20051017042228-9276cd40a784c93c
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS 2007-02-08 03:10:33 +0000
+++ b/NEWS 2007-02-08 16:28:05 +0000
@@ -62,6 +62,10 @@
continues to work, but callers accessed the FORMATTERS dictionary
directly will not.
+ * ``GPGStrategy.sign()`` will now raise ``BzrBadParameterUnicode`` if
+ you pass a Unicode string rather than an 8-bit string. Callers need
+ to be updated to encode first. (John Arbash Meinel)
+
BUGFIXES:
* ``bzr annotate`` now uses dotted revnos from the viewpoint of the
=== modified file 'bzrlib/gpg.py'
--- a/bzrlib/gpg.py 2006-10-16 01:25:46 +0000
+++ b/bzrlib/gpg.py 2007-02-08 16:28:05 +0000
@@ -76,6 +76,8 @@
self._config = config
def sign(self, content):
+ if isinstance(content, unicode):
+ raise errors.BzrBadParameterUnicode('content')
ui.ui_factory.clear_term()
preexec_fn = _set_gpg_tty
=== modified file 'bzrlib/tests/test_gpg.py'
--- a/bzrlib/tests/test_gpg.py 2006-10-11 23:08:27 +0000
+++ b/bzrlib/tests/test_gpg.py 2007-02-08 16:28:05 +0000
@@ -80,6 +80,11 @@
ui.ui_factory.clear_term = old_clear_term
self.assertEqual([True], clear_term_called)
+ def test_aborts_on_unicode(self):
+ """You can't sign Unicode text, it must be encoded first."""
+ self.assertRaises(errors.BzrBadParameterUnicode,
+ self.assertProduces, u'foo')
+
class TestDisabled(TestCase):
More information about the bazaar-commits
mailing list