summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-01-04 23:12:01 -0600
committerBenjamin Peterson <benjamin@python.org>2014-01-04 23:12:01 -0600
commit70b9d871fca4ee61c8807557645fc1e2e7d36973 (patch)
tree90d363ce033afc06ddd68a4d7002fc5b37b1823a
parentb1994d8f1647968b1898dc48c8adb788ddc0b8a6 (diff)
downloadsix-70b9d871fca4ee61c8807557645fc1e2e7d36973.tar.gz
pretend __file__ doesn't exist if the module hasn't been loaded yet (fixes #51)
-rw-r--r--CHANGES5
-rw-r--r--six.py7
2 files changed, 12 insertions, 0 deletions
diff --git a/CHANGES b/CHANGES
index 0468e6f..d8e3a17 100644
--- a/CHANGES
+++ b/CHANGES
@@ -3,6 +3,11 @@ Changelog for Six
This file lists the changes in each six version.
+1.5.1
+-----
+
+- Issue #51: Hack around the Django autoreloader after recent six.moves changes.
+
1.5.0
-----
diff --git a/six.py b/six.py
index 212af14..6b3b9b0 100644
--- a/six.py
+++ b/six.py
@@ -105,6 +105,13 @@ class MovedModule(_LazyDescr):
return _import_module(self.mod)
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:
+ raise AttributeError
_module = self._resolve()
value = getattr(_module, attr)
setattr(self, attr, value)