Commits

Anonymous committed 0503e8b

preventing a bunch of KeyErrors

Comments (0)

Files changed (2)

_line_profiler.pyx

             # Get the time again. This way, we don't record much time wasted
             # in this function.
             self.last_time[code] = LastTime(py_frame.f_lineno, hpTimer())
-        else:
+        elif code in self.last_time:
             # We are returning from a function, not executing a line. Delete
             # the last_time record.
             del self.last_time[code]
             dd[lineno] = (d.get(lineno, empty), line.rstrip("\n").rstrip("\r"))
 
         func_time = func_times[(fn, start_lineno)]
-        dd[start_lineno] = (("", "%11.6f" % (func_time * unit), "", "%5.2f" % (100*func_time / total_time)), sublines[0].rstrip('\n').rstrip('\r'))
+        dd[start_lineno] = (("", "%11.6f" % (func_time * unit), "", "%5.2f" % (100*func_time / total_time)), sublines[0].rstrip('\n').rstrip('\r') if sublines else "")
 
 
     # dump all lines