bug? pkgutil.walk_packages returns packages that result in an ImportError
chris at simplistix.co.uk
Thu Aug 26 14:51:15 CEST 2010
From the docs of pkgutils.walk_packages:
'onerror' is a function which gets called with one argument (the
name of the package which was being imported) if any exception
occurs while trying to import a package. If no onerror function is
supplied, ImportErrors are caught and ignored, while all other
exceptions are propagated, terminating the search.
My expectation of this is that if onerrors is left as None, names
yielded will be importable.
However, because the yield is before the import check, you can get
packages returned that are not importable.
This feels at odds with the docs above and I think is a bug.
If the yield were dropped to befoer the import check, we wouldn't have
what do others think?
More information about the Python-list