Add bool support to c-api by bschoenmaeckers · Pull Request #7938 · RustPython/RustPython
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: 441c7d2c-429d-4e25-be30-cee81eaeb8b8
📒 Files selected for processing (2)
crates/capi/src/boolobject.rscrates/capi/src/lib.rs
📝 Walkthrough
Walkthrough
A new boolobject module is added to the RustPython C-API layer with four exported functions: PyBool_Check (type validation), Py_IsTrue (true singleton test), Py_IsFalse (false singleton test), and PyBool_FromLong (construct boolean from c_long). The module is exported via lib.rs.
Changes
Boolean operations in C-API
| Layer / File(s) | Summary |
|---|---|
Boolean type checks and conversion crates/capi/src/boolobject.rs, crates/capi/src/lib.rs |
New boolobject module exposes PyBool_Check, Py_IsTrue, Py_IsFalse, and PyBool_FromLong functions that wrap the VM's internal boolean singleton values and are exported from the crate. |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
- RustPython/RustPython#7872: Adds
PyObject_IsTrueto the broader object C-API, while this PR introducesPy_IsTrue/Py_IsFalsespecialized for boolean singletons. - RustPython/RustPython#7871: Uses the same
define_py_check!macro pattern for type checks, showing shared C-API infrastructure for type validation functions.
Suggested reviewers
- youknowone
- ShaharNaveh
Poem
🐰 A boolean bunny hops into the fold,
WithIsTrueandIsFalse, both brave and bold,
Check types and convert with C-ABI care,
The VM's singletons now everywhere! ✨
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title 'Add bool support to c-api' clearly and accurately summarizes the main change: adding boolean object support to the C-API layer, as evidenced by the new boolobject.rs module with PyBool functions. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
| 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.
Comment @coderabbitai help to get the list of available commands and usage tips.