diff options
| author | Georg Brandl <georg@python.org> | 2006-04-30 17:42:26 (GMT) | 
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2006-04-30 17:42:26 (GMT) | 
| commit | 208badda275a7aaf722a8db87297637e161fa7aa (patch) | |
| tree | 49b9e9a1f7e60341d6a4c726a22b301df8e011e8 /Lib/inspect.py | |
| parent | 72ae6c80d489ea9d26958616d57cc37a5bd27d46 (diff) | |
| download | cpython-208badda275a7aaf722a8db87297637e161fa7aa.zip cpython-208badda275a7aaf722a8db87297637e161fa7aa.tar.gz cpython-208badda275a7aaf722a8db87297637e161fa7aa.tar.bz2  | |
Fix another problem in inspect: if the module for an object cannot be found, don't try to give its __dict__ to linecache.
Diffstat (limited to 'Lib/inspect.py')
| -rw-r--r-- | Lib/inspect.py | 6 | 
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index 4b2058e..bf7f006 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')  | 
