bug? pkgutil.walk_packages returns packages that result in an ImportError
Chris Withers
chris at simplistix.co.uk
Thu Aug 26 08:51:15 EDT 2010
Hi All,
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
this problem.
what do others think?
cheers,
Chris
More information about the Python-list
mailing list