@@ -152,11 +152,6 @@ def add(self, mimetype, content, headers=None):
152
152
else :
153
153
content = content .encode ('utf-8' )
154
154
mimetype = mimetype + ';charset=utf-8'
155
- elif 'charset' not in params :
156
- try :
157
- content .decode ('utf-8' )
158
- finally :
159
- mimetype = mimetype + ';charset=utf-8'
160
155
161
156
headers ['Content-Type' ] = mimetype
162
157
if content :
@@ -206,15 +201,15 @@ def write_multipart(fileobj, subtype='mixed', boundary=None):
206
201
207
202
>>> buf = StringIO()
208
203
>>> envelope = write_multipart(buf, boundary='==123456789==')
209
- >>> envelope.add('text/plain', 'Just testing')
204
+ >>> envelope.add('text/plain', b 'Just testing')
210
205
>>> envelope.close()
211
206
>>> print(buf.getvalue().replace(b'\r\n', b'\n').decode('utf-8'))
212
207
Content-Type: multipart/mixed; boundary="==123456789=="
213
208
<BLANKLINE>
214
209
--==123456789==
215
210
Content-Length: 12
216
211
Content-MD5: nHmX4a6el41B06x2uCpglQ==
217
- Content-Type: text/plain;charset=utf-8
212
+ Content-Type: text/plain
218
213
<BLANKLINE>
219
214
Just testing
220
215
--==123456789==--
@@ -230,7 +225,7 @@ def write_multipart(fileobj, subtype='mixed', boundary=None):
230
225
>>> buf = StringIO()
231
226
>>> envelope = write_multipart(buf, boundary='==123456789==')
232
227
>>> part = envelope.open(boundary='==abcdefghi==')
233
- >>> part.add('text/plain', 'Just testing')
228
+ >>> part.add('text/plain', u 'Just testing')
234
229
>>> part.close()
235
230
>>> envelope.close()
236
231
>>> print(buf.getvalue().replace(b'\r\n', b'\n').decode('utf-8')) #:doctest +ELLIPSIS
0 commit comments