[New-bugs-announce] [issue11676] imp.load_module and submodules - doc issue, or bug?

Dave Peck report at bugs.python.org
Fri Mar 25 22:40:27 CET 2011

New submission from Dave Peck <davepeck at gmail.com>:

If you use `import` to load a package and subpackage:

    import package
    import package.subpackage
Then the `package` module instance will contain a `subpackage` attribute:

    assert "subpackage" in dir(sys.modules['package']), "This works."
But if you use Python's `imp` module to import these packages instead, the same assertion will fail.

Is this a python documentation oversight, or a bug with the `imp` module? 

To reproduce, clone the associated hg repro and follow the instructions in the README file. Thanks!

components: Interpreter Core, Library (Lib)
hgrepos: 10
messages: 132162
nosy: Dave Peck
priority: normal
severity: normal
status: open
title: imp.load_module and submodules - doc issue, or bug?
type: behavior
versions: Python 2.5, Python 2.6, Python 2.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list