gh-132099: Accept an integer as the address for BTPROTO_HCI on Linux (GH-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.
This commit is contained in:
Serhiy Storchaka 2025-04-16 13:02:51 +03:00 committed by GitHub
parent 82f74eb234
commit 8cb177d09b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 19 additions and 5 deletions

View file

@ -2147,7 +2147,12 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
#if defined(HAVE_BLUETOOTH_BLUETOOTH_H)
unsigned short dev;
unsigned short channel = HCI_CHANNEL_RAW;
if (!PyArg_ParseTuple(args, "H|H", &dev, &channel)) {
if (PyLong_Check(args)) {
if (!PyArg_Parse(args, "H", &dev)) {
return 0;
}
}
else if (!PyArg_ParseTuple(args, "H|H", &dev, &channel)) {
PyErr_Format(PyExc_OSError,
"%s(): wrong format", caller);
return 0;