Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

If six.moves has been imported, finding.find_classes may cause an ImportErrors #11

Open
gpshead opened this issue Sep 22, 2015 · 1 comment

Comments

@gpshead
Copy link

gpshead commented Sep 22, 2015

The 'six' library includes a six.moves package that sets up a meta importer import hook to lazily load a bunch of modules only when they are first accessed. The finding.find_classes code when looping over sys.modules (via modules=ALL_IMPORTED_MODULES) is tripped up by this because as soon as it starts trying to introspect the six.moves module, it triggers lazy loading of a bunch of modules which may or may not be present in the systems given Python installation (common examples of modules that'll show up in the resulting ImportError messages: gdbm and Tkinter)

A workaround for this is to filter the list and avoid module names that start with 'six.'. Very hacky, agreed. Possibly worth considering a bug in https://pypi.python.org/pypi/six but given what it is trying to do I think code just needs to learn to play together. (i've encountered one other piece of code with this same problem due to six.moves having been imported)

I'm mailing you a CL internally, I'll let you push it upstream.

@csprabala
Copy link

Any idea when this fix will be pushed?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants