diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-11-02 22:23:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-02 22:23:43 (GMT) |
commit | cfdd7d26a72e7ae523039e40c11001c2d7ef36ba (patch) | |
tree | 1ce73e5937bbc4ca1eb396fa86c1f8cd605e0bae /Lib/inspect.py | |
parent | 8af3090cb7af967ff699d82760ff36f978631b7a (diff) | |
download | cpython-cfdd7d26a72e7ae523039e40c11001c2d7ef36ba.zip cpython-cfdd7d26a72e7ae523039e40c11001c2d7ef36ba.tar.gz cpython-cfdd7d26a72e7ae523039e40c11001c2d7ef36ba.tar.bz2 |
bpo-45406: make inspect.getmodule() return None when getabsfile() raises FileNotFoundError (GH-28824)
(cherry picked from commit a459a81530de700b3d3faeb827b22ed1c9985812)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index 531b891..6d43d8d 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -859,7 +859,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]) |