You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bring BTPROTO_SCO inline with other Bluetooth protocols #69232
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2015-09-09.15:27:22.466>labels= ['extension-modules', 'type-feature', '3.11']
title='bring BTPROTO_SCO inline with other Bluetooth protocols'updated_at=<Date2021-12-27.02:36:57.111>user='https://bugs.python.org/TimTisdall'
All of the BTPROTO_ protocols accept tuples with Bluetooth addresses as regular strings. SCO accepts a byte-string which represents a Bluetooth address. The change was made at 23ab586c427a
With the current implementation we get this error:
>>> import socket
>>> x = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_SEQPACKET, socket.BTPROTO_SCO)
>>> x.bind(socket.BDADDR_ANY)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: getsockaddrarg: wrong format
This is because socket.BDADDR_ANY is a string while the bind() is expecting a binary string. So the workaround would be to call x.bind(socket.BDADDR_ANY.encode()) .
Is it acceptable to change it to accept a regular string to match the other address methods and constants? This would be essentially a breaking change, however on something that wasn't really documented prior to bpo-24984 .
Activity
TimTisdall commentedon Sep 9, 2015
All of the BTPROTO_ protocols accept tuples with Bluetooth addresses as regular strings. SCO accepts a byte-string which represents a Bluetooth address. The change was made at 23ab586c427a
With the current implementation we get this error:
This is because socket.BDADDR_ANY is a string while the bind() is expecting a binary string. So the workaround would be to call x.bind(socket.BDADDR_ANY.encode()) .
Is it acceptable to change it to accept a regular string to match the other address methods and constants? This would be essentially a breaking change, however on something that wasn't really documented prior to bpo-24984 .
I'll submit a patch when the repo is back up...
vadmium commentedon Sep 9, 2015
Perhaps making it accept both bytes and text strings is a sensible option. Similar to how AF_INET can bind to both "localhost" and b"localhost".
TimTisdall commentedon Sep 10, 2015
Yes, then any existing implementations will continue to work.
One sticky issue with all of this... there's no existing tests as per bpo-7687 .