summaryrefslogtreecommitdiffstats
path: root/Lib/email/message.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/email/message.py')
-rw-r--r--Lib/email/message.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/email/message.py b/Lib/email/message.py
index 9d25cb0..6fc3af1 100644
--- a/Lib/email/message.py
+++ b/Lib/email/message.py
@@ -238,7 +238,7 @@ class Message:
self.del_param('charset')
self._charset = None
return
- if isinstance(charset, str):
+ if isinstance(charset, basestring):
charset = email.charset.Charset(charset)
if not isinstance(charset, email.charset.Charset):
raise TypeError(charset)
@@ -756,7 +756,9 @@ class Message:
charset = charset[2]
# charset character must be in us-ascii range
try:
- charset = unicode(charset, 'us-ascii').encode('us-ascii')
+ if isinstance(charset, str):
+ charset = unicode(charset, 'us-ascii')
+ charset = charset.encode('us-ascii')
except UnicodeError:
return failobj
# RFC 2046, $4.1.2 says charsets are not case sensitive