From f1e863e495a6c7e36221cd7d7d7dc0e4b9911ab4 Mon Sep 17 00:00:00 2001 From: Dariusz L Date: Tue, 30 Jun 2026 22:33:41 +0200 Subject: [PATCH] Normalize module name when __name__ contains OS path separators ComfyUI may set __name__ to hybrid OS-path values (e.g. 'E:\\...\\comfyui-model-resolver.core.sources.model_list'), which broke the existing split-by-dot logic. This adds a pre-normalization step that converts path separators to dots, strips drive letters and .py extensions, so _normalize_module_name reliably falls back to DEFAULT_MODULE for unknown path-derived values rather than miscounting segments. --- core/log_system/log_funcs.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/core/log_system/log_funcs.py b/core/log_system/log_funcs.py index 9534ce4..af7c706 100644 --- a/core/log_system/log_funcs.py +++ b/core/log_system/log_funcs.py @@ -64,11 +64,29 @@ def _normalize_module_name(module_name): Strips common prefixes (custom_nodes, project aliases) and ``__init__`` suffixes to produce a clean, readable module path. + + ComfyUI sets ``__name__`` to hybrid values like + ``E:\\...\\comfyui-model-resolver.core.sources.model_list`` where the + first dotted segment is a full OS path. We detect this and convert + the path portion to a dotted name before applying the normal logic. """ module_name = str(module_name or "").strip() if not module_name or module_name == "__main__": return _default_module_name + # --- path-to-dots conversion (required for ComfyUI's __name__) --- + if os.sep in module_name or "/" in module_name: + # Replace all path separators with dots so the rest of the logic + # can work uniformly on dotted segments. + normalized = module_name.replace("\\", ".").replace("/", ".") + # Remove drive letter prefix (e.g. "E:." → "") + if len(normalized) >= 2 and normalized[1] == ":": + normalized = normalized[2:].lstrip(".") + # Strip .py extension if present + if normalized.endswith(".py"): + normalized = normalized[:-3] + module_name = normalized + parts = [p for p in module_name.split(".") if p] if not parts: return _default_module_name