/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-05-06 03:06:18 UTC
  • mfrom: (7500.1.2 trunk-merge-3.1)
  • Revision ID: breezy.the.bot@gmail.com-20200506030618-131sjbc876q7on66
Merge the 3.1 branch.

Merged from https://code.launchpad.net/~jelmer/brz/trunk-merge-3.1/+merge/383481

Show diffs side-by-side

added added

removed removed

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