Skip to content

Support Linux Bluetooth socket addresses - #9243

Merged
youknowone merged 1 commit into
RustPython:mainfrom
1ndahous3:bluetooth_socket_addresses
Oct 20, 2026
Merged

youknowone merged 1 commit into
RustPython:mainfrom
1ndahous3:bluetooth_socket_addresses

Conversation

@1ndahous3

@1ndahous3 1ndahous3 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Found while investigating Linux CI failures on runners with Bluetooth support.

Summary

  • Support Linux L2CAP, RFCOMM, HCI and SCO socket addresses instead of rejecting them with bad family.
  • Return CPython-compatible Bluetooth addresses, including L2CAP CID/address type and HCI channels.
  • Match CPython's argument validation and unsigned field conversions.

AI assistance

Written with Codex (GPT-6), reviewed by a human before submission.

Summary by CodeRabbit

  • New Features
    • Added Linux Bluetooth socket support for L2CAP, RFCOMM, HCI, and SCO protocols.
    • Added conversion between Bluetooth socket addresses and platform socket structures.
    • Added Bluetooth device address parsing and formatting, including validation of hexadecimal address values.
    • Added support for reading and creating protocol-specific Bluetooth addresses through the standard socket interface.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T08:13:09.529352Z 4b0d5f7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: RustPython/RustPython/.coderabbit.yml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 30983a8a-b1bc-426b-89b6-516ddb8eca51
📥 Commits

Reviewing files that changed from the base of the PR and between 398dd70 and 4b0d5f7.

📒 Files selected for processing: 3
  • crates/host_env/src/socket.rs
  • crates/host_env/src/socket/bluetooth.rs
  • crates/stdlib/src/socket.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

The change adds Linux Bluetooth socket address support for L2CAP, RFCOMM, HCI, and SCO. It adds host-level address conversion and Bluetooth address parsing, then integrates protocol-specific input parsing and output decoding in the standard library.

Changes: Linux Bluetooth socket support

Layer / File(s) Summary
Bluetooth address model and sockaddr conversion
crates/host_env/src/socket.rs, crates/host_env/src/socket/bluetooth.rs
The Linux socket module exposes Bluetooth address types and protocol constants. Address converts to and from socket addresses. Bluetooth address parsing and formatting are also added.
Python address input and sockaddr construction
crates/stdlib/src/socket.rs
Linux AF_BLUETOOTH input supports SCO, HCI, L2CAP, and RFCOMM values. The parsed values are converted into Bluetooth socket addresses.
Sockaddr decoding and Python values
crates/stdlib/src/socket.rs
Bluetooth socket addresses decode into protocol-specific Python values, including optional L2CAP fields and scalar HCI device IDs when the channel is zero.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant PythonSocket as Python socket API
  participant StdlibSocket as stdlib socket
  participant Bluetooth as host_env Bluetooth

  PythonSocket->>StdlibSocket: Pass AF_BLUETOOTH address to extract_address
  StdlibSocket->>StdlibSocket: Parse protocol-specific input
  StdlibSocket->>Bluetooth: Convert Address to SockAddr
  Bluetooth-->>StdlibSocket: Return SockAddr
  StdlibSocket-->>PythonSocket: Return socket address

  PythonSocket->>StdlibSocket: Decode Bluetooth socket address
  StdlibSocket->>Bluetooth: Parse SockAddr with protocol
  Bluetooth-->>StdlibSocket: Return Address
  StdlibSocket->>StdlibSocket: Format protocol-specific Python value
  StdlibSocket-->>PythonSocket: Return decoded value
Loading

Suggested reviewers: youknowone

Merge Risk: ⚪ Minimal · up to 4b0d5

The change adds Linux Bluetooth socket address support for L2CAP, RFCOMM, HCI, and SCO with CPython-compatible input and output formats. No outstanding defects were identified, and it appears ready to merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: adding Linux Bluetooth socket address support.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4b0d5f715c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread crates/host_env/src/socket/bluetooth.rs

@youknowone youknowone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@youknowone
youknowone merged commit 0c5fa20 into RustPython:main Oct 20, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants