Traceback (most recent call last):
File "t.py", line 4, in <module>
print(pkg_resources.get_provider('asyncio').has_resource('events.py'))
File "/home/elt/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1404, in has_resource
return self._has(self._fn(self.module_path, resource_name))
File "/home/elt/.local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1457, in _has
"Can't perform this operation for unregistered loader type"
NotImplementedError: Can't perform this operation for unregistered loader type
The reason is that pkg_resources.get_provider() could not find a usable provider, because the __loader__ on the asyncio module was left as _ImportHookChainedLoader instead of being set to the standard SourceFileLoader. Leaving wrapt's internal loader is leaking implementation details. This did not happen previously because _ImportHookChainedLoader implemented load_module by calling to the original loader. The original loader set __loader__ to itself. Now that _ImportHookChainedLoader implements create_module, the import machinery sets __loader__ to the wrapt's loader.
The simplest way to retrocede this is:
This fails with the following traceback:
The reason is that pkg_resources.get_provider() could not find a usable provider, because the
__loader__
on the asyncio module was left as_ImportHookChainedLoader
instead of being set to the standardSourceFileLoader
. Leaving wrapt's internal loader is leaking implementation details. This did not happen previously because _ImportHookChainedLoader implemented load_module by calling to the original loader. The original loader set__loader__
to itself. Now that _ImportHookChainedLoader implements create_module, the import machinery sets__loader__
to the wrapt's loader.