Issue 19472: inspect.getsource() raises a wrong exception type (original) (raw)
I was looking at inspect.getsource(). In Python 3.3 and 3.4 either the docstring and the online doc say it raises a OSError, and in fact:
import inspect def foo(): ... pass ... inspect.getsource(foo) Traceback (most recent call last): ... OSError: could not get source code
However, getsource() calls getfile(), and this one raises a TypeError:
inspect.getsource(0) Traceback (most recent call last): ... TypeError: 0 is not a module, class, method, function, traceback, frame, or code object