diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8efae928..dc8901cc 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -26,6 +26,7 @@ Fixed * Fixed mypy requiring ``Unpack[ExtraArgs]`` that were intended to be optional. Fixes #1487. * Fixed ``KeyError`` in BlueZ ``is_connected()`` and ``get_global_bluez_manager()`` when device is not present. Fixes #1507. * Fixed BlueZ ``_wait_removed`` completion on invalid object path. Fixes #1489. +* Fixed rare unhandled exception when scanning on macOS when using ``use_bdaddr``. Fixes #1523. `0.21.1`_ (2023-09-08) ====================== diff --git a/bleak/backends/corebluetooth/scanner.py b/bleak/backends/corebluetooth/scanner.py index e6d20c2d..6452a28d 100644 --- a/bleak/backends/corebluetooth/scanner.py +++ b/bleak/backends/corebluetooth/scanner.py @@ -130,6 +130,11 @@ def callback(p: CBPeripheral, a: Dict[str, Any], r: int) -> None: address_bytes: bytes = ( self._manager.central_manager.retrieveAddressForPeripheral_(p) ) + if address_bytes is None: + logger.debug( + "Could not get Bluetooth address for %s. Ignoring this device.", + p.identifier().UUIDString(), + ) address = address_bytes.hex(":").upper() else: address = p.identifier().UUIDString()