mirror of
https://github.com/python/cpython.git
synced 2025-08-27 04:05:34 +00:00
bpo-45406: make inspect.getmodule() return None when getabsfile() raises FileNotFoundError (GH-28824)
This commit is contained in:
parent
48824fa1e2
commit
a459a81530
3 changed files with 11 additions and 1 deletions
|
@ -858,7 +858,7 @@ def getmodule(object, _filename=None):
|
|||
# Try the cache again with the absolute file name
|
||||
try:
|
||||
file = getabsfile(object, _filename)
|
||||
except TypeError:
|
||||
except (TypeError, FileNotFoundError):
|
||||
return None
|
||||
if file in modulesbyfile:
|
||||
return sys.modules.get(modulesbyfile[file])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue