← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-unique-hex-string-text into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-unique-hex-string-text into launchpad:master.

Commit message:
Make getUniqueHexString return Unicode

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/386712

This is a better default, although some call sites do require bytes so now need to encode the return value.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-unique-hex-string-text into launchpad:master.
diff --git a/lib/lp/services/signing/tests/helpers.py b/lib/lp/services/signing/tests/helpers.py
index 5675bc6..447f62c 100644
--- a/lib/lp/services/signing/tests/helpers.py
+++ b/lib/lp/services/signing/tests/helpers.py
@@ -12,7 +12,6 @@ __all__ = [
 
 import fixtures
 from nacl.public import PrivateKey
-from six import text_type
 
 from lp.services.compat import mock
 from lp.services.signing.interfaces.signingserviceclient import (
@@ -49,23 +48,26 @@ class SigningServiceClientFixture(fixtures.Fixture):
     def _generate(self, key_type, description):
         key = bytes(PrivateKey.generate().public_key)
         data = {
-            "fingerprint": text_type(self.factory.getUniqueHexString(40)),
-            "public-key": key}
+            "fingerprint": self.factory.getUniqueHexString(40),
+            "public-key": key,
+            }
         self.generate_returns.append((key_type, data))
         return data
 
     def _sign(self, key_type, fingerprint, message_name, message, mode):
         key = bytes(PrivateKey.generate().public_key)
-        signed_msg = "signed with key_type={}".format(key_type.name)
+        signed_msg = (
+            "signed with key_type={}".format(key_type.name).encode("UTF-8"))
         data = {
             'public-key': key,
-            'signed-message': signed_msg}
+            'signed-message': signed_msg,
+            }
         self.sign_returns.append((key_type, data))
         return data
 
     def _inject(self, key_type, private_key, public_key, description,
                 created_at):
-        data = {'fingerprint': text_type(self.factory.getUniqueHexString(40))}
+        data = {'fingerprint': self.factory.getUniqueHexString(40)}
         self.inject_returns.append(data)
         return data
 
diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py
index 03487e1..87ca1bc 100644
--- a/lib/lp/testing/factory.py
+++ b/lib/lp/testing/factory.py
@@ -455,7 +455,7 @@ class ObjectFactory(
             don't care.
         :return: A hexadecimal string, with 'a'-'f' in lower case.
         """
-        hex_number = '%x' % self.getUniqueInteger()
+        hex_number = u'%x' % self.getUniqueInteger()
         if digits is not None:
             hex_number = hex_number.zfill(digits)
         return hex_number
@@ -4205,7 +4205,7 @@ class BareLaunchpadObjectFactory(ObjectFactory):
         if fingerprint is None:
             fingerprint = self.getUniqueUnicode('fingerprint')
         if public_key is None:
-            public_key = self.getUniqueHexString(64)
+            public_key = self.getUniqueHexString(64).encode('ASCII')
         store = IMasterStore(SigningKey)
         signing_key = SigningKey(
             key_type=key_type, fingerprint=fingerprint, public_key=public_key,