--- linecache.py.orig	Sun Dec 30 14:57:43 2007
+++ linecache.py	Sun Dec 30 14:59:18 2007
@@ -13,16 +13,25 @@
 def getline(filename, lineno, module_globals=None):
     lines = getlines(filename, module_globals)
     if 1 <= lineno <= len(lines):
-        return lines[lineno-1]
+        try:
+            fp = open(filename, 'rU')
+            ## seek to the line number
+            fp.seek(lines[lineno-1])
+            line = fp.readline()
+            fp.close()
+        except IOError, msg:
+##          print '*** Cannot open', filename, ':', msg
+            return ''
+        else:
+            return line
     else:
         return ''
 
 
 # The cache
+cache = {}
 
-cache = {} # The cache
 
-
 def clearcache():
     """Clear the cache entirely."""
 
@@ -76,6 +85,8 @@
         return []
 
     fullname = filename
+    lines = []
+    seek = 0
     try:
         stat = os.stat(fullname)
     except os.error, msg:
@@ -98,9 +109,12 @@
                             # No luck, the PEP302 loader cannot find the source
                             # for this module.
                             return []
+                        for line in data.splitlines():
+                            lines.append(seek)
+                            seek = seek + len(line+'\n')
                         cache[filename] = (
                             len(data), None,
-                            [line+'\n' for line in data.splitlines()], fullname
+                            lines, fullname
                         )
                         return cache[filename][2]
 
@@ -126,7 +140,9 @@
             return []
     try:
         fp = open(fullname, 'rU')
-        lines = fp.readlines()
+        for line in fp:
+            lines.append(seek)
+            seek = seek + len(line)
         fp.close()
     except IOError, msg:
 ##      print '*** Cannot open', fullname, ':', msg
