Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: only import from bluetooth_adapters when running on linux #84

Merged
merged 1 commit into from
Jan 12, 2023
Merged

fix: only import from bluetooth_adapters when running on linux #84

merged 1 commit into from
Jan 12, 2023

Conversation

kroimon
Copy link
Contributor

@kroimon kroimon commented Jan 12, 2023

This avoids an exception on Windows because socket.CMSG_LEN is only available on UNIX platforms.

  File "bleak_retry_connector/__init__.py", line 18, in <module>
    from bluetooth_adapters import load_history_from_managed_objects
  File "bluetooth_adapters/__init__.py", line 12, in <module>
    from .dbus import (
  File "bluetooth_adapters/dbus.py", line 10, in <module>
    from dbus_fast import BusType, Message, MessageType, unpack_variants
  File "dbus_fast/__init__.py", line 1, in <module>
    from . import aio, glib, introspection, message_bus, proxy_object, service
  File "dbus_fast/aio/__init__.py", line 1, in <module>
    from .message_bus import MessageBus
  File "dbus_fast/aio\message_bus.py", line 29, in <module>
    from .message_reader import build_message_reader
  File "dbus_fast/aio/message_reader.py", line 7, in <module>
    from .._private.unmarshaller import Unmarshaller
  File "dbus_fast/_private/unmarshaller.py", line 16, in <module>
    UNIX_FDS_CMSG_LENGTH = socket.CMSG_LEN(MAX_UNIX_FDS_SIZE)
AttributeError: module 'socket' has no attribute 'CMSG_LEN'

@codecov
Copy link

codecov bot commented Jan 12, 2023

Codecov Report

Base: 78.20% // Head: 78.20% // No change to project coverage 👍

Coverage data is based on head (60ea7a6) compared to base (0954d2d).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #84   +/-   ##
=======================================
  Coverage   78.20%   78.20%           
=======================================
  Files           4        4           
  Lines         413      413           
  Branches       99       99           
=======================================
  Hits          323      323           
  Misses         62       62           
  Partials       28       28           
Impacted Files Coverage Δ
src/bleak_retry_connector/__init__.py 76.96% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

This avoids an exception on Windows because socket.CMSG_LEN is only available on UNIX platforms.
@bdraco
Copy link
Member

bdraco commented Jan 12, 2023

Thanks for the PR @kroimon

I think we should fix bluetooth-adapters to not require dbus-fast on windows instead.

@kroimon
Copy link
Contributor Author

kroimon commented Jan 12, 2023

Sure that's also a possibility.
I think both would probably make sense because the use of the import here is guarded by the IS_LINUX constant anyway.

@bdraco bdraco merged commit 51926f7 into Bluetooth-Devices:main Jan 12, 2023
@kroimon kroimon deleted the bluetooth_adapters-import branch March 22, 2024 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants