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.

Author ncoghlan
Recipients Pascal.Chambon, brett.cannon, eric.snow, ncoghlan
Date 2013-04-14.08:21:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1365927670.3.0.827187412278.issue17716@psf.upfronthosting.co.za>
In-reply-to
Content
The interpreter level problem covered by the current issue is that the difference between "import mypkg.module_a" and "from mypkg import module_a" is masking the fact that it is the original "import mypkg" that failed, and may still fail on the second and subsequent imports. That is, the user level code is at best dubious, but the interpreter is spitting out misleading error messages that obscure the real cause of the failure.

In the tests for #17636, we should ensure that all of the following consistently raise RuntimeError when the import fails (on both the initial and subsequent import attempts):

    import badpkg.goodmod
    raise RuntimeError("Always fails")

    from badpkg import goodmod
    raise RuntimeError("Always fails")

    from . import goodmod
    raise RuntimeError("Always fails")

Where that is the __init__.py code in the following layout:

    badpkg/
        __init__.py
        goodmod.py
History
Date User Action Args
2013-04-14 08:21:10ncoghlansetrecipients: + ncoghlan, brett.cannon, eric.snow, Pascal.Chambon
2013-04-14 08:21:10ncoghlansetmessageid: <1365927670.3.0.827187412278.issue17716@psf.upfronthosting.co.za>
2013-04-14 08:21:10ncoghlanlinkissue17716 messages
2013-04-14 08:21:10ncoghlancreate