[BUG] GPGStrategy.sign shouldn't accept Unicode

John Arbash Meinel john at arbash-meinel.com
Wed Feb 7 23:09:11 GMT 2007


We just had a problem where on some platform we passed
GPGStrategy.sign() a Unicode string to be signed. That function passes
the buffer directly to subprocess.Popen.communicate(). And it seems this
used to translate Unicode strings to 8-bit strings. (encode(ascii?))

However, we have a case that proves this cannot be counted upon, and
more importantly we shouldn't have been doing it anyway.

I'd like to do something like:
=== modified file 'bzrlib/gpg.py'
--- bzrlib/gpg.py       2006-10-16 01:25:46 +0000
+++ bzrlib/gpg.py       2007-02-07 23:08:46 +0000
@@ -27,6 +27,7 @@

 from bzrlib import (
     errors,
+    symbol_versioning,
     trace,
     ui,
     )
@@ -76,6 +77,10 @@
         self._config = config

     def sign(self, content):
+        if isinstance(content, unicode):
+            symbol_versioning.warn('Deprecated: do not pass unicode
strings to'
+                                   ' GPGStrategy.sign(), encode them
first.')
+            content = content.encode('utf-8')
         ui.ui_factory.clear_term()

         preexec_fn = _set_gpg_tty


Thoughts?

John
=:->



More information about the bazaar mailing list