← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:email-utils-not-rfc822 into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:email-utils-not-rfc822 into launchpad:master.

Commit message:
Use functions from email.utils instead of rfc822

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

rfc822 has been deprecated since Python 2.3 (!), and is gone in Python 3.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:email-utils-not-rfc822 into launchpad:master.
diff --git a/lib/lp/app/browser/tales.py b/lib/lp/app/browser/tales.py
index c732f5e..22bb6c4 100644
--- a/lib/lp/app/browser/tales.py
+++ b/lib/lp/app/browser/tales.py
@@ -10,10 +10,12 @@ from datetime import (
     datetime,
     timedelta,
     )
-from email.utils import formatdate
+from email.utils import (
+    formatdate,
+    mktime_tz,
+    )
 import math
 import os.path
-import rfc822
 import sys
 from textwrap import dedent
 
@@ -2288,8 +2290,7 @@ class DateTimeFormatterAPI:
         return "%s %s" % (self.date(), self.time())
 
     def rfc822utcdatetime(self):
-        return formatdate(
-            rfc822.mktime_tz(self._datetime.utctimetuple() + (0, )))
+        return formatdate(mktime_tz(self._datetime.utctimetuple() + (0, )))
 
     def isodate(self):
         return self._datetime.isoformat()
diff --git a/lib/lp/bugs/mail/bugnotificationbuilder.py b/lib/lp/bugs/mail/bugnotificationbuilder.py
index bad1fab..f784d30 100644
--- a/lib/lp/bugs/mail/bugnotificationbuilder.py
+++ b/lib/lp/bugs/mail/bugnotificationbuilder.py
@@ -12,9 +12,11 @@ __all__ = [
     ]
 
 from email.mime.text import MIMEText
-from email.utils import formatdate
+from email.utils import (
+    formatdate,
+    mktime_tz,
+    )
 import re
-import rfc822
 
 from zope.component import getUtility
 from zope.security.proxy import removeSecurityProxy
@@ -35,7 +37,7 @@ from lp.services.mail.sendmail import (
 
 def format_rfc2822_date(date):
     """Formats a date according to RFC2822's desires."""
-    return formatdate(rfc822.mktime_tz(date.utctimetuple() + (0, )))
+    return formatdate(mktime_tz(date.utctimetuple() + (0, )))
 
 
 def get_bugmail_from_address(person, bug):
diff --git a/lib/lp/soyuz/scripts/gina/packages.py b/lib/lp/soyuz/scripts/gina/packages.py
index a2136d9..4126b80 100644
--- a/lib/lp/soyuz/scripts/gina/packages.py
+++ b/lib/lp/soyuz/scripts/gina/packages.py
@@ -21,10 +21,10 @@ __all__ = [
     'SourcePackageData',
     ]
 
+from email.utils import parseaddr
 import glob
 import os
 import re
-import rfc822
 import shutil
 import tempfile
 
@@ -154,10 +154,10 @@ def read_dsc(package, version, component, distro_name, archive_root):
 def parse_person(val):
     """Parse a full email address into human-readable name and address."""
     # Some addresses have commas in them, as in: "Adam C. Powell, IV
-    # <hazelsct@xxxxxxxxxxxxxxxxxx>". rfc822.parseaddr seems not to
+    # <hazelsct@xxxxxxxxxxxxxxxxxx>". email.utils.parseaddr seems not to
     # handle this properly, so we munge them here.
     val = val.replace(',', '')
-    return rfc822.parseaddr(val)
+    return parseaddr(val)
 
 
 def parse_section(v):