summaryrefslogtreecommitdiffstats
path: root/Lib/email/generator.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-07-21 00:21:26 (GMT)
committerGuido van Rossum <guido@python.org>2007-07-21 00:21:26 (GMT)
commitd4eda825c7ed83822868e2e6d794e2ad4dc6c955 (patch)
tree3e66eeefe7aed19451a9483d93ac427019ab3a79 /Lib/email/generator.py
parentbf4806bac5697bd50e6ca41fcf6838f93ed9a511 (diff)
downloadcpython-d4eda825c7ed83822868e2e6d794e2ad4dc6c955.zip
cpython-d4eda825c7ed83822868e2e6d794e2ad4dc6c955.tar.gz
cpython-d4eda825c7ed83822868e2e6d794e2ad4dc6c955.tar.bz2
SF patch# 1757839 by Alexandre Vassalotti -- make test_mailbox and
test_old_mailbox pass.
Diffstat (limited to 'Lib/email/generator.py')
-rw-r--r--Lib/email/generator.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/email/generator.py b/Lib/email/generator.py
index 02b4495..c480229 100644
--- a/Lib/email/generator.py
+++ b/Lib/email/generator.py
@@ -21,14 +21,20 @@ NL = '\n'
fcre = re.compile(r'^From ', re.MULTILINE)
def _is8bitstring(s):
- if isinstance(s, str):
+ if isinstance(s, bytes):
try:
str(s, 'us-ascii')
+ return True
except UnicodeError:
+ pass
+ elif isinstance(s, str):
+ try:
+ s.decode('us-ascii')
return True
+ except UnicodeError:
+ pass
return False
-
class Generator:
"""Generates output from a Message object tree.