Skip to content

Commit

Permalink
Merge pull request #280 from pvieito/patch-2
Browse files Browse the repository at this point in the history
Safer `Core Bluetooth` presence check
  • Loading branch information
hbldh authored Sep 3, 2020
2 parents d327199 + 54cb284 commit 4eb1610
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bleak/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
BleakClientBlueZDBus as BleakClient,
) # noqa
elif platform.system() == "Darwin":
from Foundation import NSClassFromString

if NSClassFromString("CBPeripheral") is None:
raise BleakError("Bleak requires the CoreBluetooth Framework")
try:
from CoreBluetooth import CBPeripheral
except Exception as ex:
raise BleakError("Bleak requires the CoreBluetooth Framework") from ex

from bleak.backends.corebluetooth.discovery import discover # noqa
from bleak.backends.corebluetooth.scanner import (
Expand Down

0 comments on commit 4eb1610

Please sign in to comment.