Skip to content

Commit b141814

Browse files
authored
Call spec.loader.exec_module in _load_pybind11_module utility (#835)
1 parent 05a6ff5 commit b141814

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/torchcodec/_internally_replaced_utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@ def _load_pybind11_module(module_name: str, library_path: str) -> ModuleType:
4545
module_name,
4646
library_path,
4747
)
48-
if spec is None:
48+
if spec is None or spec.loader is None:
4949
raise ImportError(
50-
f"Unable to load spec for module {module_name} from path {library_path}"
50+
f"Unable to load spec or spec.loader for module {module_name} from path {library_path}"
5151
)
5252

53-
return importlib.util.module_from_spec(spec)
53+
mod = importlib.util.module_from_spec(spec)
54+
spec.loader.exec_module(mod)
55+
56+
return mod
5457

5558

5659
# Note that the return value from this function must match the value used as

0 commit comments

Comments
 (0)