launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #26423
[Merge] ~cjwatson/launchpad:fix-py3-person-remove-ensure-unicode into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:fix-py3-person-remove-ensure-unicode into launchpad:master.
Commit message:
Fix test failures from removal of ensure_unicode from PersonSet
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/398687
There were enough test failures caused by the vocabulary changes that it's worth putting a couple of `six.ensure_text` calls back in; and `PersonSet.getByEmails` now raises `UnicodeDecodeError` rather than `TypeError` in the case of invalid UTF-8 in an email address, so adjust `authenticateEmail` to expect that.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:fix-py3-person-remove-ensure-unicode into launchpad:master.
diff --git a/lib/lp/registry/vocabularies.py b/lib/lp/registry/vocabularies.py
index 7675f9c..24b5675 100644
--- a/lib/lp/registry/vocabularies.py
+++ b/lib/lp/registry/vocabularies.py
@@ -242,6 +242,7 @@ class BasePersonVocabulary:
If the token contains an '@', treat it like an email. Otherwise,
treat it like a name.
"""
+ token = six.ensure_text(token)
if "@" in token:
# This looks like an email token, so let's do an object
# lookup based on that.
@@ -737,6 +738,7 @@ class ValidPersonOrTeamVocabulary(
else:
return self.emptySelectResults()
+ text = six.ensure_text(text)
return self._doSearch(text=text, vocab_filter=vocab_filter)
def searchForTerms(self, query=None, vocab_filter=None):
diff --git a/lib/lp/services/mail/incoming.py b/lib/lp/services/mail/incoming.py
index 7bbe006..958985b 100644
--- a/lib/lp/services/mail/incoming.py
+++ b/lib/lp/services/mail/incoming.py
@@ -268,7 +268,7 @@ def authenticateEmail(mail, signature_timestamp_checker=None):
from_addr = parseaddr(mail['From'])[1]
try:
principal = authutil.getPrincipalByLogin(from_addr)
- except TypeError:
+ except (TypeError, UnicodeDecodeError):
# The email isn't valid, so don't authenticate
principal = None