Skip to content

Commit

Permalink
backends/winrt/client: fix crash in max_pdu_size_changed_handler
Browse files Browse the repository at this point in the history
It is possible that self._session is set to None when
max_pdu_size_changed_handler is called. So we can use the sender arg
instead to avoid a possible AttributeError.

Fixes #998.
  • Loading branch information
dlech committed Sep 12, 2022
1 parent d81fd3d commit 21e72cb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Fixed
* Fixed use of wrong enum in unpair function of WinRT backend.
* Fixed inconsistent return types for ``properties`` and ``descriptors`` properties of ``BleakGATTCharacteristic``.
* Handle device being removed before GetManagedObjects returns in BlueZ backend. Fixes #996.
* Fixed crash in ``max_pdu_size_changed_handler`` in WinRT backend. Fixes #998.

Removed
-------
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 @@ -279,7 +279,7 @@ def session_status_changed_event_handler(
loop.call_soon_threadsafe(handle_session_status_changed, args)

def max_pdu_size_changed_handler(sender: GattSession, args):
logger.debug("max_pdu_size_changed_handler: %d", self._session.max_pdu_size)
logger.debug("max_pdu_size_changed_handler: %d", sender.max_pdu_size)

# Start a GATT Session to connect
event = asyncio.Event()
Expand Down

0 comments on commit 21e72cb

Please sign in to comment.