Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
assignee='https://github.com/berkerpeksag'closed_at=<Date2014-09-26.21:58:57.085>created_at=<Date2012-10-25.15:49:32.881>labels= ['type-feature', 'expert-email']
title='MIMEText __init__ does not support Charset instance'updated_at=<Date2014-09-26.21:58:57.084>user='https://bugs.python.org/claudep'
When initializing a MIMEText instance, it might be desirable to set the _charset parameter to a real Charset instance, not only a charset identifier (for example to pass a Charset with customized body_encoding). Unfortunately, this is failing:
File ".../django/core/mail/message.py", line 128, in __init__
MIMEText.__init__(self, text, subtype, charset)
File "/usr/lib/python3.2/email/mime/text.py", line 29, in __init__
File "/usr/lib/python3.2/email/mime/base.py", line 25, in __init__
self.add_header('Content-Type', ctype, **_params)
File "/usr/lib/python3.2/email/message.py", line 475, in add_header
parts.append(_formatparam(k.replace('_', '-'), v))
File "/usr/lib/python3.2/email/message.py", line 67, in _formatparam
if value is not None and len(value) > 0:
TypeError: object of type 'Charset' has no len()
It is possible to later call set_charset, but the payload is already encoded (and 'Content-Transfer-Encoding' is set).
Did I miss anything?
I don't think you missed anything. It doesn't look like this has ever worked, but you'd certainly think it would. The documentation doesn't claim anything about it one way or another. That probably means we should treat it as an enhancement rather than a bug fix, but I'm open to argument on that.