# Buggy code
def _FormatDateTime(self, event_object):
    """Formats the date to a datetime object without timezone information.

    Note: timezone information must be removed due to lack of support
    by xlsxwriter and Excel.

    Args:
      event_object: the event object (instance of EventObject).

    Returns:
      A datetime object (instance of datetime.datetime)
      or a string containing 'ERROR' on OverflowError.
    """
    try:
        timestamp = timelib.Timestamp.CopyToDatetime(
            event_object.timestamp,
            timezone=self._output_mediator.timezone,
            raise_error=True,
        )

        return timestamp.replace(tzinfo=None)

    except OverflowError as exception:
        logging.error(
            (
                "Unable to copy {0:d} into a human readable timestamp with error: "
                "{1:s}. Event {2!d}:{3!d} triggered the exception."
            ).format(
                event_object.timestamp,
                exception,
                getattr(event_object, "store_number", "N/A"),
                getattr(event_object, "store_index", "N/A"),
            )
        )

        return "ERROR"


# Traceback (ValueError)
» PYTHONPATH=. ./tools/psort.py --output_format=dynamic /tmp/test.plaso
[INFO] Data files will be loaded from /home/onager/code/plaso/data by default.
datetime,timestamp_desc,source,source_long,message,parser,display_name,tag,store_number,store_index
Traceback (most recent call last):
File "./tools/psort.py", line 676, in <module>
if not Main():
File "./tools/psort.py", line 671, in Main
tool.ProcessStorage()
File "./tools/psort.py", line 623, in ProcessStorage
self._ProcessStorage()
File "./tools/psort.py", line 252, in _ProcessStorage
time_slice=time_slice, use_time_slicer=self._use_time_slicer)
File "/home/onager/code/plaso/plaso/frontend/psort.py", line 403, in ProcessStorage
analysis_queues=event_queue_producers)
File "/home/onager/code/plaso/plaso/frontend/psort.py", line 556, in ProcessEventsFromStorage
event_object = storage_file.GetSortedEntry()
File "/home/onager/code/plaso/plaso/lib/storage.py", line 1071, in GetSortedEntry
event_object = self.GetEventObject(store_number)
File "/home/onager/code/plaso/plaso/lib/storage.py", line 1131, in GetEventObject
event_object_data)
File "/home/onager/code/plaso/plaso/serializer/json_serializer.py", line 799, in ReadSerialized
return json_decoder.decode(json_string)
File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
obj, end = self.scan_once(s, idx)
File "/home/onager/code/plaso/plaso/serializer/json_serializer.py", line 249, in _ConvertDictToObject
return self._ConvertDictToPathSpec(json_dict)
File "/home/onager/code/plaso/plaso/serializer/json_serializer.py", line 211, in _ConvertDictToPathSpec
type_indicator, **json_dict)
File "/usr/lib/python2.7/dist-packages/dfvfs/path/factory.py", line 107, in NewPathSpec
return path_spec_type(**kwargs)
File "/usr/lib/python2.7/dist-packages/dfvfs/path/os_path_spec.py", line 42, in __init__
super(OSPathSpec, self).__init__(location=location, parent=parent, **kwargs)
File "/usr/lib/python2.7/dist-packages/dfvfs/path/location_path_spec.py", line 26, in __init__
super(LocationPathSpec, self).__init__(parent=parent, **kwargs)
File "/usr/lib/python2.7/dist-packages/dfvfs/path/path_spec.py", line 25, in __init__
raise ValueError(u'Unused keyword arguments.')
ValueError: Unused keyword arguments.


» ./utils/check_dependencies.py
<snip>
[OK]       dfvfs version: 20151008
<snip>

# Fixed code
def _FormatDateTime(self, event_object):
    """Formats the date to a datetime object without timezone information.

    Note: timezone information must be removed due to lack of support
    by xlsxwriter and Excel.

    Args:
      event_object: the event object (instance of EventObject).

    Returns:
      A datetime object (instance of datetime.datetime)
      or a string containing 'ERROR' on OverflowError.
    """
    try:
        timestamp = timelib.Timestamp.CopyToDatetime(
            event_object.timestamp,
            timezone=self._output_mediator.timezone,
            raise_error=True,
        )

        return timestamp.replace(tzinfo=None)

    except OverflowError as exception:
        logging.error(
            (
                "Unable to copy {0:d} into a human readable timestamp with error: "
                "{1:s}. Event {2!s}:{3!s} triggered the exception."
            ).format(
                event_object.timestamp,
                exception,
                getattr(event_object, "store_number", "N/A"),
                getattr(event_object, "store_index", "N/A"),
            )
        )

        return "ERROR"