Skip to content

Update test_resource.py to 3.14.4#7808

Merged
youknowone merged 4 commits into
RustPython:mainfrom
ShaharNaveh:update-test-resource
May 11, 2026
Merged

Update test_resource.py to 3.14.4#7808
youknowone merged 4 commits into
RustPython:mainfrom
ShaharNaveh:update-test-resource

Conversation

@ShaharNaveh
Copy link
Copy Markdown
Contributor

@ShaharNaveh ShaharNaveh commented May 9, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation and error handling in resource management functions with clearer error messages for invalid inputs and overflow conditions.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 9, 2026

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • Lib/test/test_resource.py is excluded by !Lib/**

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 63c1190a-79f4-4f93-b9f9-f478a806c824

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR refactors resource limit Python bindings from accepting i32 resource identifiers to PyIntRef. A new py2rlim helper validates Python integers, rejecting negatives and mapping overflows to Python exceptions. Both getrlimit and setrlimit functions are updated to use the new type and conversion logic.

Changes

Resource Parameter Type Migration

Layer / File(s) Summary
Module Imports
crates/stdlib/src/resource.rs
PyIntRef is added to support Python integer resource identifiers.
Conversion Helper and Type Implementations
crates/stdlib/src/resource.rs
py2rlim helper converts PyIntRef to libc::rlim_t, rejecting negatives and mapping conversion errors to Python ValueError/OverflowError. Limits ToPyObject implementation is repositioned.
Function Updates
crates/stdlib/src/resource.rs
getrlimit and setrlimit are updated to accept PyIntRef, use py2rlim for conversion, validate against RLIM_NLIMITS, and call libc functions with converted resource IDs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Resource limits once held i32 fast,
Now PyIntRef lets validation last!
Negatives rejected, overflows caught with care,
The conversion dance flows through the air. ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title claims to update 'test_resource.py' to version 3.14.4, but the actual changes are to 'crates/stdlib/src/resource.rs' with significant signature updates to getrlimit and setrlimit functions. Update the title to accurately reflect the main changes, such as 'Update resource stdlib bindings to accept PyIntRef' or similar, to match the actual changeset.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

📦 Library Dependencies

The following Lib/ modules were modified. Here are their dependencies:

[x] test: cpython/Lib/test/test_resource.py (TODO: 4)

dependencies:

dependent tests: (4 tests)

  • resource: test_os test_selectors test_subprocess test_threading

Legend:

  • [+] path exists in CPython
  • [x] up-to-date, [ ] outdated

@youknowone youknowone merged commit 8f19dff into RustPython:main May 11, 2026
26 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