Issue16324
Created on 2012-10-25 15:49 by claudep, last changed 2022-04-11 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| issue16324-1.diff | claudep, 2012-10-26 12:18 | Allow Charset to be passed to MIMEText | review | |
| issue16324_v2.diff | berker.peksag, 2014-09-26 13:09 | review | ||
| Messages (7) | |||
|---|---|---|---|
| msg173764 - (view) | Author: Claude Paroz (claudep) | Date: 2012-10-25 15:49 | |
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__
**{'charset': _charset})
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?
|
|||
| msg173793 - (view) | Author: R. David Murray (r.david.murray) * | Date: 2012-10-25 19:08 | |
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. |
|||
| msg173794 - (view) | Author: Claude Paroz (claudep) | Date: 2012-10-25 19:16 | |
It's fine for me to consider it as an enhancement. The fix might be as simple as replacing **{'charset': _charset} by **{'charset': str(_charset)} in MIMEText __init__.
|
|||
| msg227615 - (view) | Author: Berker Peksag (berker.peksag) * | Date: 2014-09-26 13:09 | |
Here's an updated patch. |
|||
| msg227617 - (view) | Author: R. David Murray (r.david.murray) * | Date: 2014-09-26 14:05 | |
The updated patch looks good to me. Go ahead and commit it. |
|||
| msg227660 - (view) | Author: Roundup Robot (python-dev) | Date: 2014-09-26 21:57 | |
New changeset d43d4d4ebf2c by Berker Peksag in branch 'default': Issue #16324: _charset parameter of MIMEText now also accepts email.charset.Charset instances. https://hg.python.org/cpython/rev/d43d4d4ebf2c |
|||
| msg227661 - (view) | Author: Berker Peksag (berker.peksag) * | Date: 2014-09-26 21:58 | |
Thanks for the patch, Claude and thanks for the review, David! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:57:37 | admin | set | github: 60528 |
| 2014-09-26 21:58:57 | berker.peksag | set | status: open -> closed messages: + msg227661 assignee: berker.peksag |
| 2014-09-26 21:57:24 | python-dev | set | nosy:
+ python-dev messages: + msg227660 |
| 2014-09-26 14:05:02 | r.david.murray | set | messages: + msg227617 |
| 2014-09-26 13:09:19 | berker.peksag | set | files:
+ issue16324_v2.diff type: behavior -> enhancement messages:
+ msg227615 |
| 2012-10-26 12:18:40 | claudep | set | files:
+ issue16324-1.diff keywords: + patch |
| 2012-10-25 19:16:55 | claudep | set | messages: + msg173794 |
| 2012-10-25 19:08:31 | r.david.murray | set | messages: + msg173793 |
| 2012-10-25 15:49:32 | claudep | create | |