# Buggy code
def set_filters(self, can_filters=None):
    """Apply filtering to all messages received by this Bus.

    Calling without passing any filters will reset the applied filters.

    Since Kvaser only supports setting one filter per handle, the filtering
    will be done in the :meth:`recv` if more than one filter is requested.

    :param list can_filters:
        A list of dictionaries each containing a "can_id" and a "can_mask".

        >>> [{"can_id": 0x11, "can_mask": 0x21}]

        A filter matches, when ``<received_can_id> & can_mask == can_id & can_mask``
    """
    if can_filters and len(can_filters) == 1:
        can_id = can_filters[0]["can_id"]
        can_mask = can_filters[0]["can_mask"]
        extended = 1 if can_filters[0].get("extended") else 0
        log.info("canlib is filtering on ID 0x%X, mask 0x%X", can_id, can_mask)
        for handle in (self._read_handle, self._write_handle):
            canSetAcceptanceFilter(handle, can_id, can_mask, extended)
    else:
        log.info("Hardware filtering has been disabled")
        for handle in (self._read_handle, self._write_handle):
            for extended in (0, 1):
                canSetAcceptanceFilter(handle, 0, 0, extended)


# Traceback (NotImplementedError)
Traceback (most recent call last):
File "pycan-test.py", line 3, in <module>
interface = KvaserBus(0)
File "/usr/local/lib/python2.7/dist-packages/can/interfaces/kvaser/canlib.py", line 361, in __init__
self.set_filters(can_filters)
File "/usr/local/lib/python2.7/dist-packages/can/interfaces/kvaser/canlib.py", line 413, in set_filters
canSetAcceptanceFilter(handle, can_id, can_mask, ext)
File "/usr/local/lib/python2.7/dist-packages/can/interfaces/kvaser/canlib.py", line 39, in _unimplemented_function
raise NotImplementedError('This function is not implemented in canlib')
NotImplementedError: This function is not implemented in canlib

# Fixed code
def set_filters(self, can_filters=None):
    """Apply filtering to all messages received by this Bus.

    Calling without passing any filters will reset the applied filters.

    Since Kvaser only supports setting one filter per handle, the filtering
    will be disabled if more than one filter is requested.

    :param list can_filters:
        A list of dictionaries each containing a "can_id", "can_mask" and
        "extended".

        >>> [{"can_id": 0x11, "can_mask": 0x21, "extended": False}]

        A filter matches, when ``<received_can_id> & can_mask == can_id & can_mask``
    """
    if can_filters and len(can_filters) == 1:
        can_id = can_filters[0]["can_id"]
        can_mask = can_filters[0]["can_mask"]
        extended = 1 if can_filters[0].get("extended") else 0
        try:
            for handle in (self._read_handle, self._write_handle):
                canSetAcceptanceFilter(handle, can_id, can_mask, extended)
        except NotImplementedError:
            log.warning("Filtering is not supported")
        else:
            log.info("canlib is filtering on ID 0x%X, mask 0x%X", can_id, can_mask)

    else:
        log.info("Hardware filtering has been disabled")
        try:
            for handle in (self._read_handle, self._write_handle):
                for extended in (0, 1):
                    canSetAcceptanceFilter(handle, 0, 0, extended)
        except NotImplementedError:
            pass