Skip to content

Commit 511865d

Browse files
committed
bpo-45406: make inspect.getmodule() return None when getabsfile() raises FileNotFoundError
1 parent b108db6 commit 511865d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Lib/inspect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ def getmodule(object, _filename=None):
859859
# Try the cache again with the absolute file name
860860
try:
861861
file = getabsfile(object, _filename)
862-
except TypeError:
862+
except (TypeError, FileNotFoundError):
863863
return None
864864
if file in modulesbyfile:
865865
return sys.modules.get(modulesbyfile[file])

0 commit comments

Comments
 (0)