New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MIMEApplication cannot access #60350
Comments
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. |
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. |
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 bpo-1424065, the MIMEApplication added after other MIME class. |
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. |
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
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: