summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-01-06 09:54:13 -0600
committerBenjamin Peterson <benjamin@python.org>2014-01-06 09:54:13 -0600
commit50cccc727a182aa1eeda55a5c075c9452062d3a6 (patch)
tree7437dbc1dbc9074514fcb341b81aab3398c166d1
parent9b05735a78c6fee4116c243800af2e33a6d9cd7f (diff)
downloadsix-50cccc727a182aa1eeda55a5c075c9452062d3a6.tar.gz
make six.moves modules appear not to have __name__ unless they are loaded (fixes #53)
-rw-r--r--CHANGES6
-rw-r--r--six.py11
2 files changed, 12 insertions, 5 deletions
diff --git a/CHANGES b/CHANGES
index d8e3a17..dfd2d7a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -3,6 +3,12 @@ Changelog for Six
This file lists the changes in each six version.
+1.5.2
+-----
+
+- Issue #53: Make the fake modules six.moves puts into sys.modules appear not to
+ have a __name__ unless they are loaded.
+
1.5.1
-----
diff --git a/six.py b/six.py
index 5dfa78d..fee090d 100644
--- a/six.py
+++ b/six.py
@@ -106,11 +106,12 @@ class MovedModule(_LazyDescr):
def __getattr__(self, attr):
# Hack around the Django autoreloader. The reloader tries to get
- # __file__ of every module in sys.modules. This doesn't work well if
- # this MovedModule is for an module that is unavailable on this machine
- # (like winreg on Unix systems). Thus, we pretend __file__ doesn't exist
- # if the module hasn't been loaded yet. See issue #51.
- if attr == "__file__" and self.mod not in sys.modules:
+ # __file__ or __name__ of every module in sys.modules. This doesn't work
+ # well if this MovedModule is for an module that is unavailable on this
+ # machine (like winreg on Unix systems). Thus, we pretend __file__ and
+ # __name__ don't exist if the module hasn't been loaded yet. See issues
+ # #51 and #53.
+ if attr in ("__file__", "__name__") and self.mod not in sys.modules:
raise AttributeError
_module = self._resolve()
value = getattr(_module, attr)