This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2015年02月24日 15:15 by bmispelon, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| issue23511.diff | bmispelon, 2015年02月24日 20:05 | review | ||
| issue23511_open_cm.diff | bmispelon, 2015年02月25日 14:05 | review | ||
| Messages (7) | |||
|---|---|---|---|
| msg236503 - (view) | Author: Baptiste Mispelon (bmispelon) * | Date: 2015年02月24日 15:15 | |
The first code example at https://docs.python.org/3.5/library/email-examples.html throws an `AttributeError` because `MIMEText`'s constructor expects a `str` object, not a `bytes` one: >>> # Import smtplib for the actual sending function ... import smtplib >>> >>> # Import the email modules we'll need ... from email.mime.text import MIMEText >>> >>> # Open a plain text file for reading. For this example, assume that ... # the text file contains only ASCII characters. ... fp = open(textfile, 'rb') >>> # Create a text/plain message ... msg = MIMEText(fp.read()) Traceback (most recent call last): File "<stdin>", line 2, in <module> File "/usr/lib/python3.4/email/mime/text.py", line 33, in __init__ _text.encode('us-ascii') AttributeError: 'bytes' object has no attribute 'encode' |
|||
| msg236539 - (view) | Author: Baptiste Mispelon (bmispelon) * | Date: 2015年02月24日 20:05 | |
Patch attached. |
|||
| msg236543 - (view) | Author: Berker Peksag (berker.peksag) * (Python committer) | Date: 2015年02月24日 20:53 | |
LGTM. |
|||
| msg236575 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2015年02月25日 13:57 | |
Looks like the example wasn't updated during the python3 transition. As long as we are changing it, we might as well make it use the file as a context manager. |
|||
| msg236576 - (view) | Author: Baptiste Mispelon (bmispelon) * | Date: 2015年02月25日 14:05 | |
I wasn't sure if that was going to be out of scope or not. Here's an attached patch that fixes the remaining usages of `open` inside `Doc/includes` to always use a context manager. |
|||
| msg236588 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2015年02月25日 16:14 | |
New changeset 89c6a6c2dd1f by Berker Peksag in branch '3.4': Issue #23511: Port email-simple.py to Python 3. https://hg.python.org/cpython/rev/89c6a6c2dd1f New changeset cb911e1fb3dc by Berker Peksag in branch 'default': Issue #23511: Port email-simple.py to Python 3. https://hg.python.org/cpython/rev/cb911e1fb3dc |
|||
| msg236590 - (view) | Author: Berker Peksag (berker.peksag) * (Python committer) | Date: 2015年02月25日 16:16 | |
Thanks for the patch, Baptiste. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:13 | admin | set | github: 67699 |
| 2015年02月25日 16:16:47 | berker.peksag | set | status: open -> closed type: enhancement messages: + msg236590 resolution: fixed stage: commit review -> resolved |
| 2015年02月25日 16:14:41 | python-dev | set | nosy:
+ python-dev messages: + msg236588 |
| 2015年02月25日 14:05:44 | bmispelon | set | files:
+ issue23511_open_cm.diff messages: + msg236576 |
| 2015年02月25日 13:57:07 | r.david.murray | set | messages: + msg236575 |
| 2015年02月24日 20:53:07 | berker.peksag | set | versions:
+ Python 3.4, Python 3.5 nosy: + r.david.murray, berker.peksag messages: + msg236543 stage: commit review |
| 2015年02月24日 20:05:21 | bmispelon | set | files:
+ issue23511.diff keywords: + patch messages: + msg236539 |
| 2015年02月24日 15:15:02 | bmispelon | create | |