# Buggy code
def ParseLine(self, parser_mediator):
    """Return an event object extracted from the current line.

    Args:
      parser_mediator: A parser mediator object (instance of ParserMediator).
    """
    if not self.attributes["time"]:
        raise errors.TimestampNotCorrectlyFormed(
            "Unable to parse timestamp, time not set."
        )

    if not self.attributes["iyear"]:
        raise errors.TimestampNotCorrectlyFormed(
            "Unable to parse timestamp, year not set."
        )

    times = self.attributes["time"].split(":")
    if self.local_zone:
        timezone = parser_mediator.timezone
    else:
        timezone = pytz.UTC

    if len(times) < 3:
        raise errors.TimestampNotCorrectlyFormed(
            ("Unable to parse timestamp, not of the format HH:MM:SS [{0:s}]").format(
                self.PrintLine()
            )
        )
    try:
        secs = times[2].split(".")
        if len(secs) == 2:
            sec, us = secs
        else:
            sec = times[2]
            us = 0

        timestamp = timelib.Timestamp.FromTimeParts(
            int(self.attributes["iyear"]),
            self.attributes["imonth"],
            self.attributes["iday"],
            int(times[0]),
            int(times[1]),
            int(sec),
            microseconds=int(us),
            timezone=timezone,
        )

    except ValueError as exception:
        raise errors.TimestampNotCorrectlyFormed(
            "Unable to parse: {0:s} with error: {1:s}".format(
                self.PrintLine(), exception
            )
        )

    event_object = self.CreateEvent(
        timestamp, getattr(self, "entry_offset", 0), self.attributes
    )
    parser_mediator.ProduceEvent(event_object)


# Traceback (UnicodeDecodeError)
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/plaso/engine/worker.py", line 169, in _ParseFileEntryWithParser
parser_object.UpdateChainAndParse(self._parser_mediator)
File "/usr/lib/python2.7/dist-packages/plaso/parsers/interface.py", line 72, in UpdateChainAndParse
self.Parse(parser_mediator, **kwargs)
File "/usr/lib/python2.7/dist-packages/plaso/parsers/interface.py", line 256, in Parse
self.ParseFileObject(parser_mediator, file_object, **kwargs)
File "/usr/lib/python2.7/dist-packages/plaso/parsers/text_parser.py", line 160, in ParseFileObject
_ = self.NextToken()
File "/usr/lib/python2.7/dist-packages/plaso/lib/lexer.py", line 191, in NextToken
return Lexer.NextToken(self)
File "/usr/lib/python2.7/dist-packages/plaso/lib/lexer.py", line 99, in NextToken
possible_next_state = callback(string=m.group(0), match=m)
File "/usr/lib/python2.7/dist-packages/plaso/parsers/text_parser.py", line 119, in ParseIncomplete
self.attributes['body'] += match.group(0)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128)

# Fixed code
def ParseLine(self, parser_mediator):
    """Return an event object extracted from the current line.

    Args:
      parser_mediator: a parser mediator object (instance of ParserMediator).
    """
    if not self.attributes["time"]:
        raise errors.TimestampNotCorrectlyFormed(
            "Unable to parse timestamp, time not set."
        )

    if not self.attributes["iyear"]:
        raise errors.TimestampNotCorrectlyFormed(
            "Unable to parse timestamp, year not set."
        )

    times = self.attributes["time"].split(":")
    if self.local_zone:
        timezone = parser_mediator.timezone
    else:
        timezone = pytz.UTC

    if len(times) < 3:
        raise errors.TimestampNotCorrectlyFormed(
            ("Unable to parse timestamp, not of the format HH:MM:SS [{0:s}]").format(
                self.PrintLine()
            )
        )
    try:
        secs = times[2].split(".")
        if len(secs) == 2:
            sec, us = secs
        else:
            sec = times[2]
            us = 0

        timestamp = timelib.Timestamp.FromTimeParts(
            int(self.attributes["iyear"]),
            self.attributes["imonth"],
            self.attributes["iday"],
            int(times[0]),
            int(times[1]),
            int(sec),
            microseconds=int(us),
            timezone=timezone,
        )

    except ValueError as exception:
        raise errors.TimestampNotCorrectlyFormed(
            "Unable to parse: {0:s} with error: {1:s}".format(
                self.PrintLine(), exception
            )
        )

    event_object = self.CreateEvent(
        timestamp, getattr(self, "entry_offset", 0), self.attributes
    )
    parser_mediator.ProduceEvent(event_object)