Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/cds/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def wrap_exec_module(self, module):
getattr(module, i, None) for i in
('__package__', '__file__', '__path__')
)
err = False
# __path__ must be an iterable of strings,
# we convert any valid __path__ to tuple of strings.
# Ref: https://docs.python.org/3/reference/import.html#module-path
Expand All @@ -50,17 +51,16 @@ def wrap_exec_module(self, module):
elif isinstance(path, str):
# Some package might change this, which is non-standard.
# There is no correct way to handle this.
# We retain the file location to maintain the original import function,
# and also record the `path` for debugging purposes.
import os.path
path = (os.path.dirname(file), path)
# Do not cache this.
err = True
else:
try:
path = tuple(path)
except TypeError:
_verbose(f"{name}.__path__ is not iterable: {path}", 1)
path = None
meta_map[name] = (package, file, path)
err = True
if not err:
meta_map[name] = (package, file, path)
return module

return wrap_exec_module
Expand Down