File tree 2 files changed +5
-0
lines changed
2 files changed +5
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,9 @@ unsafe extern "C" fn id_new(
28
28
kwds : * mut PyObject ,
29
29
) -> * mut PyObject {
30
30
if PyTuple_Size ( args) != 0 || !kwds. is_null ( ) {
31
+ // We use pyo3-ffi's `c_str!` macro to create null-terminated literals because
32
+ // Rust's string literals are not null-terminated
33
+ // On Rust 1.77 or newer you can use `c"text"` instead.
31
34
PyErr_SetString ( PyExc_TypeError , c_str ! ( "Id() takes no arguments" ) . as_ptr ( ) ) ;
32
35
return ptr:: null_mut ( ) ;
33
36
}
Original file line number Diff line number Diff line change @@ -474,6 +474,8 @@ impl<'a> FnSpec<'a> {
474
474
475
475
pub fn null_terminated_python_name ( & self , ctx : & Ctx ) -> TokenStream {
476
476
let Ctx { pyo3_path } = ctx;
477
+ let span = self . python_name . span ( ) ;
478
+ let pyo3_path = pyo3_path. to_tokens_spanned ( span) ;
477
479
let name = self . python_name . to_string ( ) ;
478
480
quote_spanned ! ( self . python_name. span( ) => #pyo3_path:: ffi:: c_str!( #name) )
479
481
}
You can’t perform that action at this time.
0 commit comments