Skip to content

zipimporter masks import errors #68980

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

Closed
AmundHov mannequin opened this issue Aug 5, 2015 · 2 comments
Closed

zipimporter masks import errors #68980

AmundHov mannequin opened this issue Aug 5, 2015 · 2 comments
Labels
3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@AmundHov
Copy link
Mannequin

AmundHov mannequin commented Aug 5, 2015

BPO 24792
Nosy @Yhg1s, @gpshead, @ncoghlan, @ericsnowcurrently, @miss-islington, @iritkatriel
PRs
  • bpo-24792: Fix zipimporter masking the cause of import errors #22204
  • 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 2020-12-20.17:06:37.498>
    created_at = <Date 2015-08-05.08:51:02.859>
    labels = ['type-bug', 'library', '3.10']
    title = 'zipimporter masks import errors'
    updated_at = <Date 2020-12-20.17:06:37.498>
    user = 'https://bugs.python.org/AmundHov'

    bugs.python.org fields:

    activity = <Date 2020-12-20.17:06:37.498>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-12-20.17:06:37.498>
    closer = 'iritkatriel'
    components = ['Library (Lib)']
    creation = <Date 2015-08-05.08:51:02.859>
    creator = 'Amund Hov'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 24792
    keywords = ['patch']
    message_count = 2.0
    messages = ['248022', '383334']
    nosy_count = 8.0
    nosy_names = ['twouters', 'gregory.p.smith', 'ncoghlan', 'eric.snow', 'superluser', 'Amund Hov', 'miss-islington', 'iritkatriel']
    pr_nums = ['22204']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue24792'
    versions = ['Python 3.10']

    @AmundHov
    Copy link
    Mannequin Author

    AmundHov mannequin commented Aug 5, 2015

    Due to mixed version .pyc files in my zipped python application I was getting inconsistent loading of certain packages.

    E.g.

    n [4]: zf.find_module('kitconsole')
    Out[4]: <zipimporter object "test_controller_test.zip">

    In [5]: zf.load_module('kitconsole')
    ---------------------------------------------------------------------------

    ZipImportError                            Traceback (most recent call last)
    <ipython-input-5-8e75885cc952> in <module>()
    ----> 1 zf.load_module('kitconsole')

    ZipImportError: can't find module 'kitconsole'

    Unpacking the archive and doing the import from the file system revealed the real issue, ImportError: Bad Magic Number.

    As an end user it was confusing that zipimporter reported being able to find the module in find_module(), but not in load_module(). Is it possible to have load_module provide a better error message when import fails? The wording now does not give any hints when searching the bug-tracker / Google.

    @AmundHov AmundHov mannequin added type-bug An unexpected behavior, bug, or error type-feature A feature request or enhancement and removed type-bug An unexpected behavior, bug, or error labels Aug 5, 2015
    @iritkatriel iritkatriel added stdlib Python modules in the Lib dir 3.8 (EOL) end of life 3.9 only security fixes 3.10 only security fixes type-bug An unexpected behavior, bug, or error and removed type-feature A feature request or enhancement labels Sep 11, 2020
    @miss-islington
    Copy link
    Contributor

    New changeset fb34096 by Irit Katriel in branch 'master':
    bpo-24792: Fix zipimporter masking the cause of import errors (GH-22204)
    fb34096

    @iritkatriel iritkatriel removed 3.8 (EOL) end of life 3.9 only security fixes labels Dec 20, 2020
    @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
    3.10 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants