diff options
author | Benjamin Peterson <benjamin@python.org> | 2014-01-08 10:39:02 -0600 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2014-01-08 10:39:02 -0600 |
commit | 6211c4ba024cb4ba415d16ced7857f824edc1f87 (patch) | |
tree | 50e7bf57ec5d0ff60f9a4486949442dd2aca1cbf | |
parent | 002274a6a1dc1d4f3ac5c99d9121b10e694f3170 (diff) | |
download | six-6211c4ba024cb4ba415d16ced7857f824edc1f87.tar.gz |
document problems with module proxies
-rw-r--r-- | documentation/index.rst | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/documentation/index.rst b/documentation/index.rst index 1bd327a..91024e0 100644 --- a/documentation/index.rst +++ b/documentation/index.rst @@ -438,6 +438,28 @@ been combined in the :mod:`py3:urllib` package in Python 3. The functionality; its structure mimics the structure of the Python 3 :mod:`py3:urllib` package. +.. note:: + + In order to make imports of the form:: + + from six.moves.cPickle import loads + + work, six places special proxy objects in in :mod:`py3:sys.modules`. These + proxies lazily load the underlying module when an attribute is fetched. This + will fail if the underlying module is not available in the Python + interpreter. For example, ``sys.modules["six.moves.winreg"].LoadKey`` would + fail on any non-Windows platform. Unfortunately, some applications try to + load attributes on every module in :mod:`py3:sys.modules`. six mitigates this + problem for some applications by pretending ``__file__`` and ``__name__`` + don't exist on lazy modules that aren't loaded. That doesn't work in every + case, though. If you are encountering this problem and don't use any from + imports directly from ``six.moves`` modules, you can workaround the issue by + removing the six proxy modules:: + + d = [name for name in sys.modules if name.startswith("six.moves.")] + for name in d: + del sys.modules[name] + Supported renames: +------------------------------+-------------------------------------+-------------------------------------+ |