Skip to content

internal: add safety comments in conversions (num-rational, num-complex, num-bigint) - #6265

Merged
Tpt merged 3 commits into
PyO3:mainfrom
xavierforge:docs/safety-comments-num
Jul 30, 2026
Merged

internal: add safety comments in conversions (num-rational, num-complex, num-bigint)#6265
Tpt merged 3 commits into
PyO3:mainfrom
xavierforge:docs/safety-comments-num

Conversation

@xavierforge

Copy link
Copy Markdown
Contributor

Part of #5487, continuing from #6256 and #6259.

Removes the #![allow(clippy::undocumented_unsafe_blocks)] exemption from the three num conversion files and adds // SAFETY: comments for their ten unsafe blocks:

  • src/conversions/num_rational.rs
  • src/conversions/num_complex.rs
  • src/conversions/num_bigint.rs

One commit per file for easier review. Verified with clippy under both the default and abi3 feature sets to cover the Py_LIMITED_API branches.

Disclosure: I used AI assistance while analyzing this code; I have personally verified each safety argument against the documented contracts, including the CPython source comment for the private _PyLong_AsByteArray.

@Tpt Tpt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks

@Tpt
Tpt added this pull request to the merge queue Jul 30, 2026
Merged via the queue into PyO3:main with commit 62094e3 Jul 30, 2026
50 checks passed
@xavierforge
xavierforge deleted the docs/safety-comments-num branch August 1, 2026 13:48
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