Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue16324

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:MIMEText __init__ does not support Charset instance
Type:enhancementStage:resolved
Components:emailVersions:Python 3.5
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To: berker.peksagNosy List: barry, berker.peksag, claudep, python-dev, r.david.murray
Priority:normalKeywords:patch

Created on2012-10-25 15:49 byclaudep, last changed2022-04-11 14:57 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
issue16324-1.diffclaudep,2012-10-26 12:18Allow Charset to be passed to MIMETextreview
issue16324_v2.diffberker.peksag,2014-09-26 13:09review
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)*(Python committer)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)*(Python committer)Date: 2014-09-26 13:09
Here's an updated patch.
msg227617 -(view)Author: R. David Murray (r.david.murray)*(Python committer)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)(Python triager)Date: 2014-09-26 21:57
New changesetd43d4d4ebf2c 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)*(Python committer)Date: 2014-09-26 21:58
Thanks for the patch, Claude and thanks for the review, David!
History
DateUserActionArgs
2022-04-11 14:57:37adminsetgithub: 60528
2014-09-26 21:58:57berker.peksagsetstatus: open -> closed
messages: +msg227661

assignee:berker.peksag
resolution: fixed
stage: patch review -> resolved
2014-09-26 21:57:24python-devsetnosy: +python-dev
messages: +msg227660
2014-09-26 14:05:02r.david.murraysetmessages: +msg227617
2014-09-26 13:09:19berker.peksagsetfiles: +issue16324_v2.diff

type: behavior -> enhancement
versions: + Python 3.5, - Python 3.2
nosy: +berker.peksag

messages: +msg227615
stage: patch review
2012-10-26 12:18:40claudepsetfiles: +issue16324-1.diff
keywords: +patch
2012-10-25 19:16:55claudepsetmessages: +msg173794
2012-10-25 19:08:31r.david.murraysetmessages: +msg173793
2012-10-25 15:49:32claudepcreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp