New submission from Petr Viktorin:
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.
----------
assignee: docs@python
components: Documentation
files: 0001-Remove-obsolete-caveat-from-reload-docs.patch
keywords: patch
messages: 242270
nosy: docs@python, encukou
priority: normal
severity: normal
status: open
title: Obsolete caveat in reload() docs
versions: Python 2.7, Python 3.4
Added file:
http://bugs.python.org/file39235/0001-Remove-obsolete-caveat-from-reload-docs.patch
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue24081>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com