Skip to content

Use ordinary fileno lookup in select - #9266

Merged
youknowone merged 2 commits into
RustPython:mainfrom
1ndahous3:select_fileno_lookup
Oct 21, 2026
Merged

youknowone merged 2 commits into
RustPython:mainfrom
1ndahous3:select_fileno_lookup

Conversation

@1ndahous3

@1ndahous3 1ndahous3 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Found while running Twisted's SelectReactor, whose waker stores fileno on the instance.

Summary

  • Resolve fileno through normal attribute lookup, including instance attributes and __getattr__.
  • Require an integer descriptor or an integer returned by fileno(), matching CPython instead of accepting arbitrary __index__ objects.
  • Preserve the native descriptor width on Windows.

AI assistance

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

Summary by CodeRabbit

  • Bug Fixes

    • Improved select.select handling of file-descriptor inputs.
    • Inputs with a direct integer value or a callable fileno() method are handled correctly.
    • Objects relying only on __index__ are rejected.
    • Missing fileno attributes and non-integer fileno() results now raise a type error.
  • Tests

    • Added coverage for instance and dynamically provided fileno attributes, readable sockets, rejected inputs, and resource cleanup.

Assisted-by: Codex:GPT-6
@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-20T22:49:46.540025Z fe9ab0c New commits
ℹ️ 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: 00f1309f-8ced-4e59-8709-7af900d364b3
📥 Commits

Reviewing files that changed from the base of the PR and between 704c1fd and fe9ab0c.

📒 Files selected for processing: 1
  • crates/stdlib/src/select.rs

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

📝 Walkthrough

select.select now accepts direct PyInt objects and otherwise resolves fileno() through attribute lookup. It rejects missing or non-integer fileno() results. Tests cover attribute resolution, rejection cases, readiness, and socket cleanup.

Changes: Selectable descriptor conversion

Layer / File(s) Summary
Descriptor conversion and validation
crates/stdlib/src/select.rs, extra_tests/snippets/stdlib_select.py
Selectable::try_from_object explicitly handles PyInt objects and requires fileno() to return a PyInt. Tests cover instance and dynamic fileno attributes, __index__-only objects, readiness, and socket cleanup.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: youknowone

Merge Risk: ⚪ Minimal · up to fe9ab

No actionable risk introduced by this PR remains.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 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: resolving fileno through ordinary attribute lookup in select.
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.
✨ 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: 704c1fd65b

ℹ️ 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/stdlib/src/select.rs Resolved
Assisted-by: Codex:GPT-6

@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: fe9ab0c52b

ℹ️ 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 extra_tests/snippets/stdlib_select.py Resolved
@youknowone
youknowone merged commit 02f4fbb into RustPython:main Oct 21, 2026
29 checks passed
@1ndahous3
1ndahous3 deleted the select_fileno_lookup branch October 25, 2026 09:34
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