Merge ~cjwatson/launchpad:py3-MessageSet-fromEmail into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: cc1eff8560998fc345050e9de0d3d5aa1bf6d08b
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-MessageSet-fromEmail
Merge into: launchpad:master
Diff against target: 21 lines (+1/-2)
1 file modified
lib/lp/services/messages/model/ (+1/-2)
Reviewer Review Type Date Requested Status
Cristian Gonzalez (community) Approve
Review via email:

Commit message

Fix MessageSet.fromEmail for Python 3

Description of the change

Using `` doesn't work here, since the address may already be Unicode. It's possible that it's a native string on Python 2 after making its way through `email.utils.parseaddr`, though, so use `six.ensure_text` instead; there's no need to do any heuristic guesswork, as the addresses come from an RFC 2047 header which has explicit encoding information.

To post a comment you must log in.
Revision history for this message
Cristian Gonzalez (cristiangsp) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/services/messages/model/ b/lib/lp/services/messages/model/
2index 49cbef2..e592daa 100644
3--- a/lib/lp/services/messages/model/
4+++ b/lib/lp/services/messages/model/
5@@ -61,7 +61,6 @@ from import config
6 from import UTC_NOW
7 from import UtcDateTimeCol
8 from import SQLBase
9-from import guess as ensure_unicode
10 from import ILibraryFileAliasSet
11 from import (
12 IDirectEmailAuthorization,
13@@ -332,7 +331,7 @@ class MessageSet:
14 if not create_missing_persons:
15 raise UnknownSender(from_addrs[0][1])
16 # autocreate a person
17- sendername = ensure_unicode(from_addrs[0][0].strip())
18+ sendername = six.ensure_text(from_addrs[0][0].strip())
19 senderemail = from_addrs[0][1].lower().strip()
20 # XXX: Guilherme Salgado 2006-08-31 bug=62344:
21 # It's hard to define what rationale to use here, and to


People subscribed via source and target branches

to status/vote changes: