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 petr.viktorin
Recipients docs@python, petr.viktorin
Date 2015-04-30.14:12:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1430403154.98.0.829139703368.issue24081@psf.upfronthosting.co.za>
In-reply-to
Content
imp.reload() and importlib.reload() docs state::

    If a module is syntactically correct but its initialization fails, the first
    :keyword:`import` statement for it does not bind its name locally, but does
    store a (partially initialized) module object in ``sys.modules``.  To reload
    the module you must first :keyword:`import` it again (this will bind the name
    to the partially initialized module object) before you can :func:`reload` it.

If I reading that correctly, "initialization" refers to executing the module, so for module containing just::

    uninitialized_variable

the following::

    >>> import sys
    >>> import x
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/tmp/x.py", line 1, in <module>
        uninitialized_variable
    NameError: name 'uninitialized_variable' is not defined

should leave me with a initialized module in sys.modules['x']. However, this is not what happens, in either Python 3.4 or 2.7::

    >>> sys.modules['x']
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    KeyError: 'x'

Here's a patch to remove the caveat in Python 3 docs.
If I missed something, and "initialization" refers to something else, it should be clarified.
History
Date User Action Args
2015-04-30 14:12:35petr.viktorinsetrecipients: + petr.viktorin, docs@python
2015-04-30 14:12:34petr.viktorinsetmessageid: <1430403154.98.0.829139703368.issue24081@psf.upfronthosting.co.za>
2015-04-30 14:12:34petr.viktorinlinkissue24081 messages
2015-04-30 14:12:34petr.viktorincreate