diff --git a/src/filters/rclpython b/src/filters/rclpython index 58a7d847..116a0e73 100755 --- a/src/filters/rclpython +++ b/src/filters/rclpython @@ -157,11 +157,15 @@ class Parser: except tokenize.TokenError as ex: msg = ex[0] line = ex[1][0] - self.out.write("

ERROR: %s

%s\n" % ( - msg, self.raw[self.lines[line]:])) + self.out.write(("

ERROR: %s

%s\n" % ( + msg, self.raw[self.lines[line]:])).encode('utf-8')) except IndentationError as ex: msg = ex[0] - self.out.write("

ERROR: %s

\n" % (msg)) + self.out.write(("

ERROR: %s

\n" % (msg)).encode('utf-8')) + except Exception as ex: + # There are other possible exceptions, for example for a + # bad encoding line (->SyntaxError). e.g. # -*- coding: lala -*- + self.out.write(("

ERROR: %s

\n" % ex).encode('utf-8')) self.out.write(b'\n') def __call__(self, toktype, toktext, startpos, endpos, line):