Skip to content
This repository was archived by the owner on Jan 23, 2024. It is now read-only.

Commit 1d9e02e

Browse files
emrekultursayEmre Kultursay
authored andcommitted
Skip over modules that don't have a __file__ field.
Otherwise, we get this error in deferred modules: Traceback (most recent call last): File "devtools/cdbg/debuglets/python/imphook2.py", line 339, in _InvokeImportCallbackBySuffix mod_root = os.path.splitext(module.__file__)[0] AttributeError: 'module' object has no attribute '__file__' ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=185320164
1 parent 1e279f4 commit 1d9e02e

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/googleclouddebugger/imphook2.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,12 @@ def GetModuleFromName(name, path):
320320
nonempty_modules = (m for m in modules if m)
321321

322322
for module in nonempty_modules:
323-
mod_root = os.path.splitext(module.__file__)[0]
323+
# TODO(emrekultursay): Write unit test to cover None case.
324+
mod_file = getattr(module, '__file__', None)
325+
if not mod_file:
326+
continue
327+
328+
mod_root = os.path.splitext(mod_file)[0]
324329

325330
# If the module is relative, add the curdir prefix to convert it to
326331
# absolute path. Note that we don't use os.path.abspath because it

0 commit comments

Comments
 (0)