-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
Inconsistency in handling Bluetooth addresses #132099
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
Comments
pythonGH-132118) (cherry picked from commit 1d97488) Co-authored-by: Serhiy Storchaka <[email protected]>
Now all protocols always accept the Bluetooth address as string and getsockname() always returns the Bluetooth address as string. * BTPROTO_SCO now accepts not only bytes, but str. * BTPROTO_SCO now checks address for embedded null. * On *BSD, BTPROTO_HCI now accepts str instead of bytes. * On FreeBSD, getsockname() for BTPROTO_HCI now returns str instead of bytes. * On NetBSD and DragonFly BDS, BTPROTO_HCI now checks address for embedded null.
Now all protocols always accept the Bluetooth address as string and getsockname() always returns the Bluetooth address as string. * BTPROTO_SCO now accepts not only bytes, but str. * BTPROTO_SCO now checks address for embedded null. * On *BSD, BTPROTO_HCI now accepts str instead of bytes. * On FreeBSD, getsockname() for BTPROTO_HCI now returns str instead of bytes. * On NetBSD and DragonFly BDS, BTPROTO_HCI now checks address for embedded null.
Now all protocols always accept the Bluetooth address as string and getsockname() always returns the Bluetooth address as string. * BTPROTO_SCO now accepts not only bytes, but str. * BTPROTO_SCO now checks address for embedded null. * On *BSD, BTPROTO_HCI now accepts str instead of bytes. * On FreeBSD, getsockname() for BTPROTO_HCI now returns str instead of bytes. * On NetBSD and DragonFly BDS, BTPROTO_HCI now checks address for embedded null.
…H-132486) Now all protocols always accept the Bluetooth address as string and getsockname() always returns the Bluetooth address as string. * BTPROTO_SCO now accepts not only bytes, but str. * BTPROTO_SCO now checks address for embedded null. * On *BSD, BTPROTO_HCI now accepts str instead of bytes. * On FreeBSD, getsockname() for BTPROTO_HCI now returns str instead of bytes. * On NetBSD and DragonFly BDS, BTPROTO_HCI now checks address for embedded null. (cherry picked from commit 1fc1df8) Co-authored-by: Serhiy Storchaka <[email protected]>
…H-132497) Now all protocols always accept the Bluetooth address as string and getsockname() always returns the Bluetooth address as string. * BTPROTO_SCO now accepts not only bytes, but str. * BTPROTO_SCO now checks address for embedded null. * On *BSD, BTPROTO_HCI now accepts str instead of bytes. * On FreeBSD, getsockname() for BTPROTO_HCI now returns str instead of bytes. * On NetBSD and DragonFly BSD, BTPROTO_HCI now checks address for embedded null. (cherry picked from commit 1fc1df8)
Fortunately, the code was completely broken on *BSD systems, so most of this inconsistencies was shielded by other bugs. We were able to change the accepted and returned types without breaking code even more. The only inconsistency left is in the BTPROTO_HCI protocol on Linux: accepted address is a tuple, but |
…Linux Previously only an integer packed in a tuple was accepted, while getsockname() could return a raw integer. Now the result of getsockname() is always acceptable as an address.
…H-132525) Previously only an integer packed in a tuple was accepted, while getsockname() could return a raw integer. Now the result of getsockname() is always acceptable as an address.
Bug report
bdaddr
, not a tuple.bdaddr
is a bytes object, not a string.bdaddr
as a string, others accept it as a bytes object.getsockname()
returns it as a string or a bytes object, and this is not always consistent with the accepted type.getsockname()
not always return an address in the acceptable format. It returnsdevice_id
when the acceptable format is a tuple(device_id,)
, can return a string when the acceptable format is a bytes object.First problem should be solved by updating the documentation.
For second problem, I propose to make both string and bytes be accepted as a Bluetooth address. Also, if a 1-tuple is accepted, then its element should be accepted, and if
bdaddr
is accepted, then a 1-tuple(bdaddr,)
should be accepted.The third problem cannot be resolved in backward compatible way. The solution for the second problem formally fixes incompatibility between input and output formats, but formats are still inconsistent between protocols. And after adding support for
hci_channel
(see #70145), the type of thegetsockname()
result will depend on thehci_channel
value.Linked PRs
The text was updated successfully, but these errors were encountered: