sqlite3: fix isolation_level TypeError message to match CPython - #8313
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe SQLite module adds typed parsing for ChangesSQLite isolation level handling
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/stdlib/src/_sqlite3.rs`:
- Around line 354-355: Update the set_isolation_level setter to accept
PySetterValue<IsolationLevelArg> instead of PySetterValue<Option<PyStrRef>>, and
unwrap the IsolationLevelArg in its assignment branch before applying the value.
Preserve the existing setter behavior while ensuring invalid assignments use the
same custom TypeError handling as ConnectArgs.
- Around line 333-345: Update IsolationLevelArg::try_from_object so the
TypeError produced when downcast::<PyStr>() fails includes the rejected object's
type name, matching CPython's “isolation_level must be str or None, not {type}”
format. Use the PyObjectRef returned by the downcast error to obtain its class
name while preserving the existing acceptance of str and None.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 3b1bca36-d053-4c9f-ae2e-ad68479cb7bf
⛔ Files ignored due to path filters (1)
Lib/test/test_sqlite3/test_regression.pyis excluded by!Lib/**
📒 Files selected for processing (1)
crates/stdlib/src/_sqlite3.rs
774972c to
f383600
Compare
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [x] lib: cpython/Lib/sqlite3 dependencies:
dependent tests: (2 tests)
Legend:
|
Assisted-by: GitHub Copilot:claude-sonnet-4-6
f383600 to
a71a04b
Compare
Summary
Fixes the
isolation_levelargument type validation insqlite3.connect()andConnection.__init__()to raise a properTypeErrorwith the message"isolation_level must be str or None"when a non-str, non-None value is supplied, matching CPython behavior.CPython reference: https://github.com/python/cpython/blob/60fdb3192b897168ec0418fb0ea6c8d2d49ea513/Modules/_sqlite/connection.c#L72-L93
Summary by CodeRabbit
Summary by CodeRabbit
isolation_levelsetting.Connection.isolation_levelproperty now reliably accepts either a string value orNone.Nonebehavior and ensuring transactional behavior stays aligned.