From: Georg Brandl Date: Sun, 30 Apr 2006 17:42:26 +0000 (+0000) Subject: Fix another problem in inspect: if the module for an object cannot be found, don... X-Git-Tag: v2.5b1~755 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=208badda275a7aaf722a8db87297637e161fa7aa;p=thirdparty%2FPython%2Fcpython.git Fix another problem in inspect: if the module for an object cannot be found, don't try to give its __dict__ to linecache. --- diff --git a/Lib/inspect.py b/Lib/inspect.py index 4b2058e4379c..bf7f006bad2f 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -412,7 +412,11 @@ def findsource(object): in the file and the line number indexes a line in that list. An IOError is raised if the source code cannot be retrieved.""" file = getsourcefile(object) or getfile(object) - lines = linecache.getlines(file, getmodule(object).__dict__) + module = getmodule(object) + if module: + lines = linecache.getlines(file, module.__dict__) + else: + lines = linecache.getlines(file) if not lines: raise IOError('could not get source code')