]> granicus.if.org Git - python/commitdiff
Fix another problem in inspect: if the module for an object cannot be found, don...
authorGeorg Brandl <georg@python.org>
Sun, 30 Apr 2006 17:42:26 +0000 (17:42 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 30 Apr 2006 17:42:26 +0000 (17:42 +0000)
Lib/inspect.py

index 4b2058e4379c91534e54fe8eac7380004a07ef7e..bf7f006bad2f6624144dad639ff0bb1f057f2747 100644 (file)
@@ -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')