Skip to content

Commit

Permalink
winrt/client: fix AttributeError in _ensure_success
Browse files Browse the repository at this point in the history
result could be None, in which case, result.status would raise an
AttributeError. `status` is the intended value in any case.
  • Loading branch information
dlech committed Nov 23, 2022
1 parent b0074d3 commit 6520268
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Changed
* Deprecated ``BLEDevice.rssi`` and ``BLEDevice.metadata``. Fixes #1025.
* ``BLEDevice`` now uses ``__slots__`` to reduce memory usage.

Fixed
-----
- Fixed ``AttributeError`` in ``_ensure_success`` in WinRT backend.

Fixed
-----
Expand Down
2 changes: 1 addition & 1 deletion bleak/backends/winrt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def _ensure_success(result: Any, attr: Optional[str], fail_msg: str) -> Any:
if status == GattCommunicationStatus.UNREACHABLE:
raise BleakError(f"{fail_msg}: Unreachable")

raise BleakError(f"{fail_msg}: Unexpected status code 0x{result.status:02X}")
raise BleakError(f"{fail_msg}: Unexpected status code 0x{status:02X}")


class WinRTClientArgs(TypedDict, total=False):
Expand Down

0 comments on commit 6520268

Please sign in to comment.