Skip to content

Adding ssize_t_cast to support passing size_t or ssize_t values where ssize_t is needed. #3219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 28, 2021

Conversation

rwgk
Copy link
Collaborator

@rwgk rwgk commented Aug 25, 2021

Description

This PR solves the problem described under PR #2692, but with a more general and more thorough implementation, including full unit test coverage for all functions with modified signatures.

The entire include/pybind11 directory was inspected for static_cast<ssize_t> and (ssize_t) C-style casts. A couple tangential minor enhancements are included in this PR.

clang-format-diff was applied.

Suggested changelog entry:

The pybind11 proxy types ``str``, ``bytes``, ``bytearray``, ``tuple``, ``list`` now consistently support passing ``ssize_t`` values for sizes and indexes. Previously, only ``size_t`` was accepted in several interfaces.

@rwgk rwgk changed the title safe_ssize_t experiment Adding ssize_t_cast to support passing size_t or ssize_t values where ssize_t is needed. Aug 28, 2021
@rwgk rwgk marked this pull request as ready for review August 28, 2021 17:53
@rwgk
Copy link
Collaborator Author

rwgk commented Aug 28, 2021

The one macos failure is just a flake (the job never actually ran).

@rwgk
Copy link
Collaborator Author

rwgk commented Aug 28, 2021

Thanks @Skylion007 for the approval!

@rwgk rwgk merged commit 777352f into pybind:master Aug 28, 2021
@rwgk rwgk deleted the safe_ssize_t branch August 28, 2021 23:40
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label Aug 28, 2021
@henryiii henryiii removed the needs changelog Possibly needs a changelog entry label Sep 16, 2021
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.

3 participants