Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
loader: PyiFrozenImporter: store loader state in custom object type
Our `PyiFrozenImporter.find_spec` implementation uses `ModuleSpec.loader_state` to store the original entry name under which the module can be found within the PYZ archive. The `PyiFrozenImporter.exec_module` then uses this information to retrieve the module's code object from the PYZ archive, even if the module's name (in `ModuleSpec.name`) is changed. However, it seems that when using `importlib.util.LazyLoader`, `PyiFrozenImporer.exec_module` gets called with module object whose spec contains modified `loader_state`. Therefore, have our `find_spec` use a custom object type for `loader_state`; this allows `exec_module` to always determine whether the `loader_state` came from our `find_spec` or not. For now, in the latter case we raise an error.
- Loading branch information