no crash when column detection fails
authorEgon Valdmees <egon.valdmees@skype.net>
Wed, 1 Jun 2011 06:46:57 +0000 (09:46 +0300)
committerEgon Valdmees <egon.valdmees@skype.net>
Wed, 1 Jun 2011 06:46:57 +0000 (09:46 +0300)
python/londiste/handlers/dispatch.py

index 0a9e954ec1ef838663a5552be97787074c1528ae..81e10d583f121e012c789b323841418bf413b138 100644 (file)
@@ -591,7 +591,10 @@ class EncodingValidator:
             raise exc
         # find starting position of line with error and log warning
         _line_start = exc.object.rfind('\n', 0, exc.start) + 1
-        _col = self.columns[exc.object.count('\t', _line_start, exc.start)]
+        try:
+            _col = self.columns[exc.object.count('\t', _line_start, exc.start)]
+        except IndexError:
+            _col = '<unknown>'
         _msg = "replacing invalid %s sequence %r in column %s"%\
                (self.encoding, exc.object[exc.start:exc.end], _col)
         self.log.warning(_msg)