[3.13] gh-132099: Harmonize Bluetooth address handling (GH-132486) (GH-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 1fc1df8dcc)
This commit is contained in:
Serhiy Storchaka 2025-04-14 19:36:04 +03:00 committed by GitHub
parent a50aa3325b
commit d321b6ec82
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 58 additions and 38 deletions

View file

@ -147,9 +147,8 @@ created. Socket addresses are represented as follows:
- On Linux it accepts a tuple ``(device_id,)`` where ``device_id``
is an integer specifying the number of the Bluetooth device.
- On FreeBSD, NetBSD and DragonFly BSD it accepts ``bdaddr`` where ``bdaddr``
is a :class:`bytes` object containing the Bluetooth address in a
string format. (ex. ``b'12:23:34:45:56:67'``)
- On FreeBSD, NetBSD and DragonFly BSD it accepts ``bdaddr``
where ``bdaddr`` is the Bluetooth address as a string.
.. versionchanged:: 3.2
NetBSD and DragonFlyBSD support added.
@ -157,10 +156,10 @@ created. Socket addresses are represented as follows:
.. versionchanged:: 3.13.3
FreeBSD support added.
- :const:`BTPROTO_SCO` accepts ``bdaddr`` where ``bdaddr`` is a
:class:`bytes` object containing the Bluetooth address in a
string format. (ex. ``b'12:23:34:45:56:67'``) This protocol is not
supported under FreeBSD.
- :const:`BTPROTO_SCO` accepts ``bdaddr`` where ``bdaddr`` is
the Bluetooth address as a string or a :class:`bytes` object.
(ex. ``'12:23:34:45:56:67'`` or ``b'12:23:34:45:56:67'``)
This protocol is not supported under FreeBSD.
- :const:`AF_ALG` is a Linux-only socket based interface to Kernel
cryptography. An algorithm socket is configured with a tuple of two to four