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 2012年10月05日 20:10 by yinian1992, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| __init__.patch | yinian1992, 2012年10月05日 20:10 | patch | review | |
| Messages (4) | |||
|---|---|---|---|
| msg172126 - (view) | Author: Aifen Qin (yinian1992) * | Date: 2012年10月05日 20:10 | |
I have a python 2.7.3 installation both on Debian 6 and Windows 7. And under both environment email.mime.application cannot access. >>> email.mime.application Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'application' It seems that the import list of email module's __init__.py doesn't include it. |
|||
| msg172131 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2012年10月05日 20:24 | |
This is by design. If you want to load the application module, you have to do so explicitly: import email.mime.application This is similar to the way many other packages are organized. An __init__ file importing a submodule is the (relatively) exceptional case rather than the common case. This is so that applications that do not need particular submodules do not incur the performance and memory hit of importing those submodules implicitly. |
|||
| msg172169 - (view) | Author: Aifen Qin (yinian1992) * | Date: 2012年10月06日 05:02 | |
These MIME except MIMEApplication can be directly accessed. >>> import email >>> email.mime.Text <email.LazyImporter object at 0xb755d20c> >>> email.mime.Application Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'Application' According to Lib\email\__init__.py, it uses LazyImporter to deal with name mapping from new-style names to old-style name, and the _MIMENAMES list just doesn't include 'Application'. This causes the behavior inconformity. As issue1424065, the MIMEApplication added after other MIME class. |
|||
| msg172170 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2012年10月06日 05:38 | |
Ah, I'd forgotten python2 email used the lazy importer. We dropped that in python3. I don't think that I want to fix this, since you have to do the import in python3 anyway. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:36 | admin | set | github: 60350 |
| 2012年10月06日 05:38:19 | r.david.murray | set | nosy:
+ barry messages: + msg172170 components: + email |
| 2012年10月06日 05:02:40 | yinian1992 | set | messages: + msg172169 |
| 2012年10月05日 20:24:38 | r.david.murray | set | status: open -> closed nosy: + r.david.murray messages: + msg172131 resolution: not a bug stage: resolved |
| 2012年10月05日 20:10:49 | yinian1992 | create | |