Skip to content

sqlite3: reject negative fetchmany values#7240

Merged
youknowone merged 2 commits intoRustPython:mainfrom
ever0de:fix/reject-negative-values-fetchmany
Feb 27, 2026
Merged

sqlite3: reject negative fetchmany values#7240
youknowone merged 2 commits intoRustPython:mainfrom
ever0de:fix/reject-negative-values-fetchmany

Conversation

@ever0de
Copy link
Contributor

@ever0de ever0de commented Feb 27, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Improved input validation for the fetchmany operation: negative size arguments are now rejected with a clear error, while omitted sizes fall back to the existing default arraysize. This prevents processing of invalid values and ensures predictable error handling and behavior for callers.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4b4e56f and 14a34bb.

📒 Files selected for processing (1)
  • crates/stdlib/src/_sqlite3.rs

📝 Walkthrough

Walkthrough

The SQLite3 fetchmany implementation now validates the optional size argument: negative values raise a ValueError; a provided non-negative size is used; when size is None, the cursor's existing arraysize is used as the fallback.

Changes

Cohort / File(s) Summary
SQLite3 Cursor fetchmany Validation
crates/stdlib/src/_sqlite3.rs
Validate optional size in fetchmany; return ValueError for negative sizes, use provided non-negative size, otherwise fall back to cursor arraysize (replaces previous unwrap_or_else behavior).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 I nibble code beneath the moonlight bright,
Fetchmany now checks sizes with delight,
No negatives hopping through my gate,
Arraysize waits when none dictate,
A tidy burrow, clean and right.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding validation to reject negative values in the fetchmany function.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
Contributor

github-actions bot commented Feb 27, 2026

📦 Library Dependencies

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

[x] lib: cpython/Lib/sqlite3
[ ] test: cpython/Lib/test/test_sqlite3 (TODO: 81)

dependencies:

  • sqlite3

dependent tests: (2 tests)

  • sqlite3: test_dbm_sqlite3 test_sqlite3

Legend:

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

@ever0de ever0de force-pushed the fix/reject-negative-values-fetchmany branch from 719acaa to 47eb4df Compare February 27, 2026 08:14
@ever0de ever0de force-pushed the fix/reject-negative-values-fetchmany branch from 47eb4df to 4b4e56f Compare February 27, 2026 08:15
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/stdlib/src/_sqlite3.rs`:
- Line 1889: Fix the typo in the ValueError message emitted by the fetchmany
code path: update the string passed to vm.new_value_error in the fetchmany
return statement (the return Err(vm.new_value_error("fetchmany many not be
negative")) call) to a correct message such as "fetchmany may not be negative"
or "size must not be negative" so the error text is accurate and clear.

ℹ️ Review info

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 09cf492 and 4b4e56f.

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

@youknowone youknowone merged commit c5472e2 into RustPython:main Feb 27, 2026
13 of 14 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