Commits

Alexandre Conrad committed 81a82fc

add a try/except block if case of file parsing error, and report ignored error

Comments (0)

Files changed (2)

coverage/parser.py

         statements.
 
         """
-        self._raw_parse()
+        try:
+            self._raw_parse()
+        except:
+            raise NoSource("Couldn't parse file: %s" % self.filename)
 
         excluded_lines = self.first_lines(self.excluded)
         ignore = excluded_lines + list(self.docstrings)

coverage/report.py

         for cu in self.code_units:
             try:
                 report_fn(cu, self.coverage._analyze(cu))
-            except (NoSource, NotPython):
+            except (NoSource, NotPython), err:
                 if not self.ignore_errors:
                     raise
+                print("%s -- ignoring" % err)