From fc57ec912eec9da4c33d8db5416fdb2dada706e7 2021-11-15 18:30:49 From: Nikita Kniazev Date: 2021-11-15 18:30:49 Subject: [PATCH] Handle changed exception type from inspect.getabsfile (bpo-44648) https://bugs.python.org/issue44648 (Python 3.10+) --- diff --git a/IPython/core/oinspect.py b/IPython/core/oinspect.py index ab25eee..09b7470 100644 --- a/IPython/core/oinspect.py +++ b/IPython/core/oinspect.py @@ -305,13 +305,13 @@ def find_file(obj) -> str: fname = None try: fname = inspect.getabsfile(obj) - except TypeError: + except (OSError, TypeError): # For an instance, the file that matters is where its class was # declared. if hasattr(obj, '__class__'): try: fname = inspect.getabsfile(obj.__class__) - except TypeError: + except (OSError, TypeError): # Can happen for builtins pass except: