gh-132099: Accept an integer as the address for BTPROTO_HCI on Linux by serhiy-storchaka · Pull Request #132525 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Doc/library/socket.rst
8 changes: 6 additions & 2 deletions Lib/test/test_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -2745,6 +2745,12 @@ def testBindHciSocket(self):
addr = s.getsockname()
self.assertEqual(addr, dev)

with (self.subTest('integer'),
socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW, socket.BTPROTO_HCI) as s):
s.bind(dev)
addr = s.getsockname()
self.assertEqual(addr, dev)

with (self.subTest('channel=HCI_CHANNEL_RAW'),
socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW, socket.BTPROTO_HCI) as s):
channel = socket.HCI_CHANNEL_RAW
Expand Down Expand Up @@ -2789,8 +2795,6 @@ def testBadHciAddr(self):
s.bind(())
with self.assertRaises(OSError):
s.bind((dev, socket.HCI_CHANNEL_RAW, 0, 0))
with self.assertRaises(OSError):
s.bind(dev)
with self.assertRaises(OSError):
s.bind(socket.BDADDR_ANY)
with self.assertRaises(OSError):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The Bluetooth socket with the :data:`~socket.BTPROTO_HCI` protocol on Linux
now accepts an address in the format of an integer ``device_id``, not only a
tuple ``(device_id,)``.
7 changes: 6 additions & 1 deletion Modules/socketmodule.c