# Buggy code
def parse_msg(message):
    if message.member == "InterfacesAdded":
        msg_path = message.body[0]
        try:
            device_interface = message.body[1].get("org.bluez.Device1", {})
        except Exception as e:
            raise e
        devices[msg_path] = (
            {**devices[msg_path], **device_interface}
            if msg_path in devices
            else device_interface
        )
    elif message.member == "PropertiesChanged":
        iface, changed, invalidated = message.body
        if iface != defs.DEVICE_INTERFACE:
            return

        msg_path = message.path
        # the PropertiesChanged signal only sends changed properties, so we
        # need to get remaining properties from cached_devices. However, we
        # don't want to add all cached_devices to the devices dict since
        # they may not actually be nearby or powered on.
        if msg_path not in devices and msg_path in cached_devices:
            devices[msg_path] = cached_devices[msg_path]
        devices[msg_path] = (
            {**devices[msg_path], **changed} if msg_path in devices else changed
        )
    else:
        msg_path = message.path
        logger.info(
            "{0}, {1} ({2}): {3}".format(
                message.member, message.interface, message.path, message.body
            )
        )

    logger.info(
        "{0}, {1} ({2} dBm), Object Path: {3}".format(
            *_device_info(msg_path, devices.get(msg_path))
        )
    )


# Traceback (builtins.AttributeError)
Unhandled Error
Traceback (most recent call last):
File "/home/usr/dir/virtualEnv/lib/python3.6/site-packages/txdbus/protocol.py", line 141, in dataReceived
self.rawDBusMessageReceived(raw_msg)
File "/home/usr/dir/virtualEnv/lib/python3.6/site-packages/txdbus/protocol.py", line 262, in rawDBusMessageReceived
self.signalReceived(m)
File "/home/usr/dir/virtualEnv/lib/python3.6/site-packages/txdbus/client.py", line 643, in signalReceived
self.router.routeMessage(msig)
File "/home/usr/dir/virtualEnv/lib/python3.6/site-packages/txdbus/router.py", line 128, in routeMessage
r.match(m)
--- <exception caught here> ---
File "/home/usr/dir/virtualEnv/lib/python3.6/site-packages/txdbus/router.py", line 67, in match
self.callback(m)
File "/home/usr/dir/virtualEnv/lib/python3.6/site-packages/bleak/backends/bluezdbus/discovery.py", line 109, in parse_msg
*_device_info(msg_path, devices.get(msg_path))
File "/home/usr/dir/virtualEnv/lib/python3.6/site-packages/bleak/backends/bluezdbus/discovery.py", line 39, in _device_info
name = props.get("Name", props.get("Alias", path.split("/")[-1]))
builtins.AttributeError: 'NoneType' object has no attribute 'get'

# Fixed code
def parse_msg(message):
    if message.member == "InterfacesAdded":
        msg_path = message.body[0]
        try:
            device_interface = message.body[1].get("org.bluez.Device1", {})
        except Exception as e:
            raise e
        devices[msg_path] = (
            {**devices[msg_path], **device_interface}
            if msg_path in devices
            else device_interface
        )
    elif message.member == "PropertiesChanged":
        iface, changed, invalidated = message.body
        if iface != defs.DEVICE_INTERFACE:
            return

        msg_path = message.path
        # the PropertiesChanged signal only sends changed properties, so we
        # need to get remaining properties from cached_devices. However, we
        # don't want to add all cached_devices to the devices dict since
        # they may not actually be nearby or powered on.
        if msg_path not in devices and msg_path in cached_devices:
            devices[msg_path] = cached_devices[msg_path]
        devices[msg_path] = (
            {**devices[msg_path], **changed} if msg_path in devices else changed
        )
    elif (
        message.member == "InterfacesRemoved"
        and message.body[1][0] == defs.BATTERY_INTERFACE
    ):
        logger.info(
            "{0}, {1} ({2}): {3}".format(
                message.member, message.interface, message.path, message.body
            )
        )
        return
    else:
        msg_path = message.path
        logger.info(
            "{0}, {1} ({2}): {3}".format(
                message.member, message.interface, message.path, message.body
            )
        )

    logger.info(
        "{0}, {1} ({2} dBm), Object Path: {3}".format(
            *_device_info(msg_path, devices.get(msg_path))
        )
    )