diff --git a/pyo3-macros-backend/src/method.rs b/pyo3-macros-backend/src/method.rs index 0f29afd4..a2114d35 100644 --- a/pyo3-macros-backend/src/method.rs +++ b/pyo3-macros-backend/src/method.rs @@ -115,12 +115,12 @@ impl FnType { } FnType::FnClass | FnType::FnNewClass => { quote! { - _pyo3::types::PyType::from_type_ptr(_py, _slf as *mut _pyo3::ffi::PyTypeObject), + _pyo3::types::PyType::from_type_ptr(py, _slf as *mut _pyo3::ffi::PyTypeObject), } } FnType::FnModule => { quote! { - _py.from_borrowed_ptr::<_pyo3::types::PyModule>(_slf), + py.from_borrowed_ptr::<_pyo3::types::PyModule>(_slf), } } } @@ -155,7 +155,7 @@ impl ExtractErrorMode { impl SelfType { pub fn receiver(&self, cls: &syn::Type, error_mode: ExtractErrorMode) -> TokenStream { - let py = syn::Ident::new("_py", Span::call_site()); + let py = syn::Ident::new("py", Span::call_site()); let slf = syn::Ident::new("_slf", Span::call_site()); match self { SelfType::Receiver { span, mutable } => { @@ -409,7 +409,7 @@ impl<'a> FnSpec<'a> { cls: Option<&syn::Type>, ) -> Result { let self_arg = self.tp.self_arg(cls, ExtractErrorMode::Raise); - let py = syn::Ident::new("_py", Span::call_site()); + let py = syn::Ident::new("py", Span::call_site()); let func_name = &self.name; let rust_call = |args: Vec| { diff --git a/pyo3-macros-backend/src/pyclass.rs b/pyo3-macros-backend/src/pyclass.rs index 440e300d..2494f562 100644 --- a/pyo3-macros-backend/src/pyclass.rs +++ b/pyo3-macros-backend/src/pyclass.rs @@ -1070,7 +1070,7 @@ impl<'a> PyClassImplsBuilder<'a> { quote! { impl _pyo3::impl_::pyclass::PyClassWithFreeList for #cls { #[inline] - fn get_free_list(_py: _pyo3::Python<'_>) -> &mut _pyo3::impl_::freelist::FreeList<*mut _pyo3::ffi::PyObject> { + fn get_free_list(py: _pyo3::Python<'_>) -> &mut _pyo3::impl_::freelist::FreeList<*mut _pyo3::ffi::PyObject> { static mut FREELIST: *mut _pyo3::impl_::freelist::FreeList<*mut _pyo3::ffi::PyObject> = 0 as *mut _; unsafe { if FREELIST.is_null() { diff --git a/pyo3-macros-backend/src/pymethod.rs b/pyo3-macros-backend/src/pymethod.rs index b745cb4b..5ea418da 100644 --- a/pyo3-macros-backend/src/pymethod.rs +++ b/pyo3-macros-backend/src/pymethod.rs @@ -494,7 +494,7 @@ fn impl_call_setter( let name = &spec.name; let fncall = if py_arg.is_some() { - quote!(#cls::#name(#slf, _py, _val)) + quote!(#cls::#name(#slf, py, _val)) } else { quote!(#cls::#name(#slf, _val)) }; @@ -563,18 +563,18 @@ pub fn impl_py_setter_def( let associated_method = quote! { #cfg_attrs unsafe fn #wrapper_ident( - _py: _pyo3::Python<'_>, + py: _pyo3::Python<'_>, _slf: *mut _pyo3::ffi::PyObject, _value: *mut _pyo3::ffi::PyObject, ) -> _pyo3::PyResult<::std::os::raw::c_int> { - let _value = _py + let _value = py .from_borrowed_ptr_or_opt(_value) .ok_or_else(|| { _pyo3::exceptions::PyAttributeError::new_err("can't delete attribute") })?; let _val = _pyo3::FromPyObject::extract(_value)?; - _pyo3::callback::convert(_py, #setter_impl) + _pyo3::callback::convert(py, #setter_impl) } }; @@ -609,7 +609,7 @@ fn impl_call_getter( let name = &spec.name; let fncall = if py_arg.is_some() { - quote!(#cls::#name(#slf, _py)) + quote!(#cls::#name(#slf, py)) } else { quote!(#cls::#name(#slf)) }; @@ -655,7 +655,7 @@ pub fn impl_py_getter_def( } => { let call = impl_call_getter(cls, spec, self_type)?; quote! { - _pyo3::callback::convert(_py, #call) + _pyo3::callback::convert(py, #call) } } }; @@ -691,7 +691,7 @@ pub fn impl_py_getter_def( let associated_method = quote! { #cfg_attrs unsafe fn #wrapper_ident( - _py: _pyo3::Python<'_>, + py: _pyo3::Python<'_>, _slf: *mut _pyo3::ffi::PyObject ) -> _pyo3::PyResult<*mut _pyo3::ffi::PyObject> { #body @@ -1084,7 +1084,7 @@ impl SlotDef { spec.name.span() => format!("`{}` must be `unsafe fn`", method_name) ); } - let py = syn::Ident::new("_py", Span::call_site()); + let py = syn::Ident::new("py", Span::call_site()); let arg_types: &Vec<_> = &arguments.iter().map(|arg| arg.ffi_type()).collect(); let arg_idents: &Vec<_> = &(0..arguments.len()) .map(|i| format_ident!("arg{}", i)) @@ -1192,7 +1192,7 @@ impl SlotFragmentDef { let fragment_trait = format_ident!("PyClass{}SlotFragment", fragment); let method = syn::Ident::new(fragment, Span::call_site()); let wrapper_ident = format_ident!("__pymethod_{}__", fragment); - let py = syn::Ident::new("_py", Span::call_site()); + let py = syn::Ident::new("py", Span::call_site()); let arg_types: &Vec<_> = &arguments.iter().map(|arg| arg.ffi_type()).collect(); let arg_idents: &Vec<_> = &(0..arguments.len()) .map(|i| format_ident!("arg{}", i))