diff --git a/src/function.rs b/src/function.rs index f9028912..c3d7409d 100644 --- a/src/function.rs +++ b/src/function.rs @@ -63,6 +63,8 @@ macro_rules! py_fn { ml_doc: 0 as *const $crate::_detail::libc::c_char }; unsafe { + [ method_def_ $f ].ml_name = + concat!(stringify!($f), "\0").as_ptr() as *const _; $crate::_detail::py_fn_impl(&mut [ method_def_ $f ]) } }}) diff --git a/src/rustobject/method.rs b/src/rustobject/method.rs index aba81775..9894f953 100644 --- a/src/rustobject/method.rs +++ b/src/rustobject/method.rs @@ -86,12 +86,16 @@ macro_rules! py_method { } static mut [ method_def_ $f ]: $crate::_detail::ffi::PyMethodDef = $crate::_detail::ffi::PyMethodDef { //ml_name: bytes!(stringify!($f), "\0"), - ml_name: b"\0" as *const u8 as *const $crate::_detail::libc::c_char, + ml_name: 0 as *const $crate::_detail::libc::c_char, ml_meth: Some([ wrap_ $f ]), ml_flags: $crate::_detail::ffi::METH_VARARGS, ml_doc: 0 as *const $crate::_detail::libc::c_char }; - unsafe { $crate::_detail::py_method_impl(&mut [ method_def_ $f ], $f) } + unsafe { + [ method_def_ $f ].ml_name = + concat!(stringify!($f), "\0").as_ptr() as *const _; + $crate::_detail::py_method_impl(&mut [ method_def_ $f ], $f) + } }}) }