Commits

Robert Kern committed 38fa1f8

ENH: Warn if LineProfiler is asked to profile something it can't.

  • Participants
  • Parent commits 0b555e6

Comments (0)

Files changed (1)

_line_profiler.pyx

             self.add_function(func)
 
     def add_function(self, func):
-        code = func.func_code
+        """ Record line profiling information for the given Python function.
+        """
+        try:
+            code = func.func_code
+        except AttributeError:
+            import warnings
+            warnings.warn("Could not extract a code object for the object %r" % (func,))
+            return
         if code not in self.code_map:
             self.code_map[code] = {}
             self.functions.append(func)