Skip to content

Fix test_poll::test_poll3 #5718

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 28, 2025
Merged

Fix test_poll::test_poll3 #5718

merged 2 commits into from
Apr 28, 2025

Conversation

youknowone
Copy link
Member

I asked github copilot chat to find one of easy to fix TODO: RUSTPYTHON in the test files and try to fix one of them.

The result with minor edits is the first commit.

Next, I asked to refactor them with:

By looking current changes, I found the eventmask parsing is repeated in both functions. Rather than that, please add `PyEventMask` type as `pub struct PyEventMask(u16)` to retrieve the pattern.

How `Fildes` is doing with `impl TryFromObject for Fildes`  will be helpful to understand how to handle the pattern.

The result with minor edits is the second commit.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request fixes the failing test_poll3 by addressing the integer overflow issue and refactoring the eventmask parsing logic into a dedicated type.

  • Introduces a new EventMask type and implements TryFromObject for it.
  • Refactors the register and modify methods in the poll implementation to use EventMask.
  • Removes the expected failure decorator from test_poll3 after the fix.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
stdlib/src/select.rs Adds EventMask type and refactors eventmask usage.
Lib/test/test_poll.py Removes the expected failure decorator for test_poll3.
Comments suppressed due to low confidence (2)

Lib/test/test_poll.py:152

  • [nitpick] With the applied fix, ensure that test_poll3 now adequately validates the overflow scenario without relying on an expected failure declaration.
# TODO: RUSTPYTHON int overflow

stdlib/src/select.rs:426

  • The PR description mentioned a 'PyEventMask' wrapping a u16, but the implementation uses i16. Please verify that using i16 is intentional and aligns with the expected semantics.
pub struct EventMask(pub i16);

@youknowone youknowone merged commit ff10a64 into RustPython:main Apr 28, 2025
11 checks passed
@youknowone youknowone deleted the test-poll3 branch April 28, 2025 03:29
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.

1 participant