/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/email_message.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-02-14 03:16:54 UTC
  • mfrom: (7479.2.3 no-more-python2)
  • Revision ID: breezy.the.bot@gmail.com-20200214031654-bp1xtv2jr9nmhto3
Drop python2 support.

Merged from https://code.launchpad.net/~jelmer/brz/no-more-python2/+merge/378694

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from __future__ import absolute_import
20
20
 
21
 
try:
22
 
    from email.message import Message
23
 
    from email.header import Header
24
 
    from email.mime.multipart import MIMEMultipart
25
 
    from email.mime.text import MIMEText
26
 
    from email.utils import formataddr, parseaddr
27
 
except ImportError:   # python < 3
28
 
    from email import (
29
 
        Header,
30
 
        Message,
31
 
        MIMEMultipart,
32
 
        MIMEText,
33
 
        )
34
 
    from email.Utils import formataddr, parseaddr
 
21
from email.message import Message
 
22
from email.header import Header
 
23
from email.mime.multipart import MIMEMultipart
 
24
from email.mime.text import MIMEText
 
25
from email.utils import formataddr, parseaddr
35
26
from . import __version__ as _breezy_version
36
27
from .errors import BzrBadParameterNotUnicode
37
28
from .osutils import safe_unicode
38
 
from .sixish import (
39
 
    text_type,
40
 
    )
41
29
from .smtp_connection import SMTPConnection
42
30
 
43
31
 
70
58
        self._body = body
71
59
        self._parts = []
72
60
 
73
 
        if isinstance(to_address, (bytes, text_type)):
 
61
        if isinstance(to_address, (bytes, str)):
74
62
            to_address = [to_address]
75
63
 
76
64
        to_addresses = []
180
168
        :param address: An unicode string, or UTF-8 byte string.
181
169
        :return: A possibly RFC2047-encoded string.
182
170
        """
183
 
        if not isinstance(address, (str, text_type)):
 
171
        if not isinstance(address, str):
184
172
            raise BzrBadParameterNotUnicode(address)
185
173
        # Can't call Header over all the address, because that encodes both the
186
174
        # name and the email address, which is not permitted by RFCs.
204
192
        # avoid base64 when it's not necessary in order to be most compatible
205
193
        # with the capabilities of the receiving side, we check with encode()
206
194
        # and decode() whether the body is actually ascii-only.
207
 
        if isinstance(string_, text_type):
 
195
        if isinstance(string_, str):
208
196
            try:
209
197
                return (string_.encode('ascii'), 'ascii')
210
198
            except UnicodeEncodeError: