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
1diff --git a/lib/lp/registry/vocabularies.py b/lib/lp/registry/vocabularies.py
2index 7675f9c..24b5675 100644
3--- a/lib/lp/registry/vocabularies.py
4+++ b/lib/lp/registry/vocabularies.py
5@@ -242,6 +242,7 @@ class BasePersonVocabulary:
6 If the token contains an '@', treat it like an email. Otherwise,
7 treat it like a name.
8 """
9+ token = six.ensure_text(token)
10 if "@" in token:
11 # This looks like an email token, so let's do an object
12 # lookup based on that.
13@@ -737,6 +738,7 @@ class ValidPersonOrTeamVocabulary(
14 else:
15 return self.emptySelectResults()
16
17+ text = six.ensure_text(text)
18 return self._doSearch(text=text, vocab_filter=vocab_filter)
19
20 def searchForTerms(self, query=None, vocab_filter=None):
21diff --git a/lib/lp/services/mail/incoming.py b/lib/lp/services/mail/incoming.py
22index 7bbe006..958985b 100644
23--- a/lib/lp/services/mail/incoming.py
24+++ b/lib/lp/services/mail/incoming.py
25@@ -268,7 +268,7 @@ def authenticateEmail(mail, signature_timestamp_checker=None):
26 from_addr = parseaddr(mail['From'])[1]
27 try:
28 principal = authutil.getPrincipalByLogin(from_addr)
29- except TypeError:
30+ except (TypeError, UnicodeDecodeError):
31 # The email isn't valid, so don't authenticate
32 principal = None
33

Subscribers

People subscribed via source and target branches

to status/vote changes: