Skip to content

Commit e09f301

Browse files
committed
Fix duplicated function identification in module_map
1 parent 2b8861c commit e09f301

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

hexrd/module_map.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,25 @@ def load_module(self, fullname):
139139
for old_path, new_paths in file_map.items():
140140
if old_path.suffix not in ("", ".py") or not "hexrd" in old_path.parts:
141141
continue
142-
if path_to_module(old_path) == fullname:
142+
try:
143+
old_mod = path_to_module(old_path)
144+
except ValueError:
145+
continue
146+
147+
if old_mod == fullname or old_mod.startswith(fullname + "."):
143148
for p in new_paths:
144149
candidate = path_to_module(p)
145150
if candidate != mapped_module:
146151
extra_candidates.append(candidate)
147-
break
148152

149153
if extra_candidates:
150-
for candidate in extra_candidates:
154+
seen = set()
155+
deduped: list[str] = []
156+
for c in extra_candidates:
157+
if c not in seen:
158+
seen.add(c)
159+
deduped.append(c)
160+
for candidate in deduped:
151161
try:
152162
cand_mod = importlib.import_module(candidate)
153163
except Exception:

0 commit comments

Comments
 (0)