summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-06-08 21:14:22 -0700
committerBenjamin Peterson <benjamin@python.org>2014-06-08 21:14:22 -0700
commit55aa9ec8a644eb42aed7c7439e96078f0b9736f5 (patch)
tree51716be2becb4dfc4b5a87888805d9c08298f141
parentbbfabd80f80874743b31a603f49fe4b0d35d8a15 (diff)
downloadsix-55aa9ec8a644eb42aed7c7439e96078f0b9736f5.tar.gz
fix importing when sys.meta_path is empty (fixes #72)
-rw-r--r--CHANGES5
-rw-r--r--six.py21
2 files changed, 16 insertions, 10 deletions
diff --git a/CHANGES b/CHANGES
index b5fabfa..b921827 100644
--- a/CHANGES
+++ b/CHANGES
@@ -3,6 +3,11 @@ Changelog for six
This file lists the changes in each six version.
+1.7.2
+-----
+
+- Issue #72: Fix installing on Python 2.
+
1.7.1
-----
diff --git a/six.py b/six.py
index 25f8cd3..589b7ac 100644
--- a/six.py
+++ b/six.py
@@ -741,15 +741,16 @@ except NameError:
# Remove other six meta path importers, since they cause problems. This can
# happen if six is removed from sys.modules and then reloaded. (Setuptools does
# this for some reason.)
-for i, importer in enumerate(sys.meta_path):
- # Here's some real nastiness: Another "instance" of the six module might be
- # floating around. Therefore, we can't use isinstance() to check for the six
- # meta path importer, since the other six instance will have inserted an
- # importer with different class.
- if (type(importer).__name__ == "_SixMetaPathImporter" and
- importer.name == __name__):
- del sys.meta_path[i]
- break
-del i, importer
+if sys.meta_path:
+ for i, importer in enumerate(sys.meta_path):
+ # Here's some real nastiness: Another "instance" of the six module might
+ # be floating around. Therefore, we can't use isinstance() to check for
+ # the six meta path importer, since the other six instance will have
+ # inserted an importer with different class.
+ if (type(importer).__name__ == "_SixMetaPathImporter" and
+ importer.name == __name__):
+ del sys.meta_path[i]
+ break
+ del i, importer
# Finally, add the importer to the meta path import hook.
sys.meta_path.append(_importer)