diff -r ede0a342ed7e Lib/inspect.py --- a/Lib/inspect.py Thu Jan 23 16:49:22 2014 +0200 +++ b/Lib/inspect.py Thu Jan 23 15:15:30 2014 -0500 @@ -516,9 +516,10 @@ return object.__file__ raise TypeError('{!r} is a built-in module'.format(object)) if isclass(object): - object = sys.modules.get(object.__module__) - if hasattr(object, '__file__'): - return object.__file__ + if hasattr(object, '__module__'): + object = sys.modules.get(object.__module__) + if hasattr(object, '__file__'): + return object.__file__ raise TypeError('{!r} is a built-in class'.format(object)) if ismethod(object): object = object.__func__