Skip to content

Conversation

@bschoenmaeckers
Copy link
Member

@bschoenmaeckers bschoenmaeckers commented Oct 15, 2025

Testing if we can add support for this before python 3.15.

closes #4003

}

if !(*writer).obj.is_null() {
if crate::_PyBytes_Resize(&mut (*writer).obj, size) > 0 {
Copy link
Member Author

Choose a reason for hiding this comment

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

It’s a shame that _PyBytes_Resize is not available on the limited api. 😢

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it's viable to just use a Vec<u8> until calling .finish(). This might defeat the point of the API for users, but at the same time it would let us support it cleanly on all versions 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder if it's viable to just use a Vec<u8> until calling .finish(). This might defeat the point of the API for users, but at the same time it would let us support it cleanly on all versions 🤔

I was hesitant to fallback to Vec for the same reason. But it seems fine to do it like this to make it work.

@bschoenmaeckers bschoenmaeckers force-pushed the byteswriter branch 3 times, most recently from 517ced7 to ddcc3f2 Compare October 17, 2025 08:54
@bschoenmaeckers
Copy link
Member Author

How can I make pyo3-ffi-check happy? It is complaining that PyBytesWriter does not exist on pre-1.15. This is expected but I cannot let it point to the existing _PyBytesWriter because the layout is different.

 error[E0412]: cannot find type `PyBytesWriter` in module `bindings` --> src\main.rs:70:5 | 70 | pyo3_ffi_check_macro::for_all_structs!(check_struct); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in `bindings` 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants