diff options
Diffstat (limited to 'Lib/email/generator.py')
-rw-r--r-- | Lib/email/generator.py | 10 |
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. |