Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Update test_resource.py to 3.14.4#7808

Open
ShaharNaveh wants to merge 2 commits intoRustPython:mainfrom
ShaharNaveh:update-test-resource
Open

Update test_resource.py to 3.14.4#7808
ShaharNaveh wants to merge 2 commits intoRustPython: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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: ac6702d0-9783-4a76-870a-898afed5c987

📥 Commits

Reviewing files that changed from the base of the PR and between e10a27b and 425014b.

⛔ Files ignored due to path filters (1)
  • Lib/test/test_resource.py is excluded by !Lib/**
📒 Files selected for processing (1)
  • crates/stdlib/src/resource.rs

📝 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: 3)

dependencies:

dependent tests: (4 tests)

  • resource: test_os test_selectors test_subprocess test_threading

Legend:

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

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