Skip to content

Commit 732ec9c

Browse files
authored
Handle 'stub' modules that don't have a __spec__ (#328)
1 parent e0f9b2f commit 732ec9c

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

‎tools/please_pex/ChangeLog‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Version 3.0.4
2+
-------------
3+
* Handle 'stub' modules that don't have a __spec__
4+
15
Version 3.0.3
26
-------------
37
* Fix `importlib.resources` for some usages relating to packages in module_dir (#324)

‎tools/please_pex/VERSION‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.3
1+
3.0.4

‎tools/please_pex/pex/plz.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,10 @@ def create_module(self, spec):
154154
# Carry over submodule_search_locations from the real module's spec, otherwise
155155
# importlib.resources (which relies on it to find a package's files) breaks once
156156
# the module's __spec__ gets overwritten with this one.
157-
real_spec = module.__spec__
158-
spec.submodule_search_locations = real_spec.submodule_search_locations
159-
self._real_specs[spec.name] = real_spec
157+
real_spec = getattr(module, "__spec__", None)
158+
if real_spec is not None:
159+
spec.submodule_search_locations = real_spec.submodule_search_locations
160+
self._real_specs[spec.name] = real_spec
160161
sys.modules[spec.name] = module
161162
return module
162163

0 commit comments

Comments
 (0)