Skip to content
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

Closed
yinian1992 mannequin opened this issue Oct 5, 2012 · 4 comments
Closed

MIMEApplication cannot access #60350

yinian1992 mannequin opened this issue Oct 5, 2012 · 4 comments
Labels
stdlib Python modules in the Lib dir topic-email

Comments

@yinian1992
Copy link
Mannequin

yinian1992 mannequin commented Oct 5, 2012

BPO 16146
Nosy @warsaw, @bitdancer, @yinian1992
Files
  • init.patch: patch
  • 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:

    assignee = None
    closed_at = <Date 2012-10-05.20:24:38.271>
    created_at = <Date 2012-10-05.20:10:49.317>
    labels = ['invalid', 'library', 'expert-email']
    title = 'MIMEApplication cannot access'
    updated_at = <Date 2012-10-06.05:38:19.416>
    user = 'https://github.com/yinian1992'

    bugs.python.org fields:

    activity = <Date 2012-10-06.05:38:19.416>
    actor = 'r.david.murray'
    assignee = 'none'
    closed = True
    closed_date = <Date 2012-10-05.20:24:38.271>
    closer = 'r.david.murray'
    components = ['Library (Lib)', 'email']
    creation = <Date 2012-10-05.20:10:49.317>
    creator = 'yinian1992'
    dependencies = []
    files = ['27439']
    hgrepos = []
    issue_num = 16146
    keywords = ['patch']
    message_count = 4.0
    messages = ['172126', '172131', '172169', '172170']
    nosy_count = 3.0
    nosy_names = ['barry', 'r.david.murray', 'yinian1992']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue16146'
    versions = ['Python 2.7']

    @yinian1992
    Copy link
    Mannequin Author

    yinian1992 mannequin commented Oct 5, 2012

    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.

    @yinian1992 yinian1992 mannequin added the stdlib Python modules in the Lib dir label Oct 5, 2012
    @bitdancer
    Copy link
    Member

    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.

    @yinian1992
    Copy link
    Mannequin Author

    yinian1992 mannequin commented Oct 6, 2012

    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.

    @bitdancer
    Copy link
    Member

    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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir topic-email
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant