Merge ~cjwatson/launchpad:fix-py3-person-remove-ensure-unicode into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: fa0b7e157ab72e43d6baa44c8928cb098224cdcb
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:fix-py3-person-remove-ensure-unicode
Merge into: launchpad:master
Diff against target: 32 lines (+3/-1)
2 files modified
lib/lp/registry/vocabularies.py (+2/-0)
lib/lp/services/mail/incoming.py (+1/-1)
Reviewer Review Type Date Requested Status
Tom Wardill (community) Approve
Review via email: mp+398687@code.launchpad.net

Commit message

Fix test failures from removal of ensure_unicode from PersonSet

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Tom Wardill (twom) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
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:
242 If the token contains an '@', treat it like an email. Otherwise,242 If the token contains an '@', treat it like an email. Otherwise,
243 treat it like a name.243 treat it like a name.
244 """244 """
245 token = six.ensure_text(token)
245 if "@" in token:246 if "@" in token:
246 # This looks like an email token, so let's do an object247 # This looks like an email token, so let's do an object
247 # lookup based on that.248 # lookup based on that.
@@ -737,6 +738,7 @@ class ValidPersonOrTeamVocabulary(
737 else:738 else:
738 return self.emptySelectResults()739 return self.emptySelectResults()
739740
741 text = six.ensure_text(text)
740 return self._doSearch(text=text, vocab_filter=vocab_filter)742 return self._doSearch(text=text, vocab_filter=vocab_filter)
741743
742 def searchForTerms(self, query=None, vocab_filter=None):744 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):
268 from_addr = parseaddr(mail['From'])[1]268 from_addr = parseaddr(mail['From'])[1]
269 try:269 try:
270 principal = authutil.getPrincipalByLogin(from_addr)270 principal = authutil.getPrincipalByLogin(from_addr)
271 except TypeError:271 except (TypeError, UnicodeDecodeError):
272 # The email isn't valid, so don't authenticate272 # The email isn't valid, so don't authenticate
273 principal = None273 principal = None
274274

Subscribers

People subscribed via source and target branches

to status/vote changes: