Edgewall Software

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#11890 closed task (fixed)

Remove Python 2.1 to 2.4 compatibility for email modules

Reported by: Peter Suter Owned by: Peter Suter
Priority: normal Milestone: 1.1.3
Component: general Version:
Severity: normal Keywords: python26
Cc: Branch:
Release Notes:

Removed support for missing email module (Python 2.1) and old module names (Python 2.4).

API Changes:
Internal Changes:


In #386 email imports were changed to local imports for Python 2.1 compatibility. We could again use normal imports.

Also in Python 2.5 all email submodules have been renamed according to PEP 8 standards. We still use the old uppercase names.

  • trac/notification/compat.py

    diff -r e60f921d031d -r 4d1945219ada trac/notification/compat.py
    a b  
    1616import re
    1717from abc import ABCMeta, abstractmethod
     18from email.utils import formatdate
    1920from genshi.builder import tag
    175176            reactivate(t)
    177178    def send(self, torcpts, ccrcpts, mime_headers={}):
    178         from email.Utils import formatdate
    179179        body = self._format_body()
    180180        public_cc = self.config.getbool('notification', 'use_public_cc')
    181181        headers = {
  • trac/notification/mail.py

    diff -r e60f921d031d -r 4d1945219ada trac/notification/mail.py
    a b  
    2020import re
    2121import smtplib
    2222import time
    23 from email.MIMEMultipart import MIMEMultipart
    24 from email.MIMEText import MIMEText
    25 from email.Utils import formatdate, parseaddr, getaddresses
     23from email.charset import BASE64, QP, SHORTEST, Charset
     24from email.header import Header
     25from email.mime.multipart import MIMEMultipart
     26from email.mime.text import MIMEText
     27from email.utils import formatdate, parseaddr, getaddresses
    2628from hashlib import md5
    2729from subprocess import Popen, PIPE
    6971    Quoted-Printable, and 'none' for no encoding, in which case mails will
    7072    be sent as 7bit if the content is all ASCII, or 8bit otherwise.
    7173    """
    72     from email.Charset import BASE64, QP, SHORTEST, Charset
    7374    charset = Charset()
    7475    charset.input_charset = 'utf-8'
    7576    charset.output_charset = 'utf-8'
    9495def create_header(key, name, charset):
    9596    """Create an appropriate email Header."""
    96     from email.Header import Header
    9797    maxlength = MAXHEADERLEN-(len(key)+2)
    9898    # Do not sent ridiculous short headers
    9999    if maxlength < 10:
  • trac/util/__init__.py

    diff -r e60f921d031d -r 4d1945219ada trac/util/__init__.py
    a b  
    744744        else:
    745745            return {}
    746746    import email
     747    import email.errors
    747748    from trac.util.translation import _
    748749    attrs = ('author', 'author-email', 'license', 'home-page', 'summary',
    749750             'description', 'version')
    760761                metadata=metadata, dist=dist, err=to_unicode(e))
    761762        for attr in attrs:
    762763            info[normalize(attr)] = err
    763     except email.Errors.MessageError as e:
     764    except email.errors.MessageError as e:
    764765        err = _("Failed to parse %(metadata)s file for %(dist)s: %(err)s",
    765766                metadata=metadata, dist=dist, err=to_unicode(e))
    766767        for attr in attrs:

Attachments (0)

Change History (2)

comment:1 by Peter Suter, 8 years ago

Owner: set to Peter Suter
Status: newassigned

comment:2 by Peter Suter, 8 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Committed in [13577].

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Peter Suter.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Peter Suter to the specified user.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.