Skip to content

Commit 91b8902

Browse files
Update codeflash/code_utils/codeflash_wrap_decorator.py
Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com>
1 parent fb9555e commit 91b8902

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

codeflash/code_utils/codeflash_wrap_decorator.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,15 @@ def _extract_class_name_tracer(frame_locals: dict[str, Any]) -> str | None:
5151

5252

5353
def _get_module_name_cf_tracer(frame: FrameType | None) -> str:
54-
with contextlib.suppress(Exception):
54+
try:
5555
test_module = inspect.getmodule(frame)
56-
if test_module and hasattr(test_module, "__name__"):
57-
return test_module.__name__
56+
except Exception:
57+
test_module = None
58+
59+
if test_module is not None:
60+
module_name = getattr(test_module, "__name__", None)
61+
if module_name is not None:
62+
return module_name
5863

5964
if frame is not None:
6065
return frame.f_globals.get("__name__", "unknown_module")

0 commit comments

Comments
 (0)