diff options
author | Benjamin Peterson <benjamin@python.org> | 2014-06-08 21:14:22 -0700 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2014-06-08 21:14:22 -0700 |
commit | 55aa9ec8a644eb42aed7c7439e96078f0b9736f5 (patch) | |
tree | 51716be2becb4dfc4b5a87888805d9c08298f141 | |
parent | bbfabd80f80874743b31a603f49fe4b0d35d8a15 (diff) | |
download | six-55aa9ec8a644eb42aed7c7439e96078f0b9736f5.tar.gz |
fix importing when sys.meta_path is empty (fixes #72)
-rw-r--r-- | CHANGES | 5 | ||||
-rw-r--r-- | six.py | 21 |
2 files changed, 16 insertions, 10 deletions
@@ -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 ----- @@ -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) |