Skip to content

Commit

Permalink
macros: _py -> py
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Jul 30, 2023
1 parent 00a6ce6 commit 0f796e7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions pyo3-macros-backend/src/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,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),
}
}
}
Expand Down Expand Up @@ -156,7 +156,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 } => {
Expand Down Expand Up @@ -421,7 +421,7 @@ impl<'a> FnSpec<'a> {
) -> Result<TokenStream> {
let deprecations = &self.deprecations;
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<TokenStream>| {
Expand Down
2 changes: 1 addition & 1 deletion pyo3-macros-backend/src/pyclass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
18 changes: 9 additions & 9 deletions pyo3-macros-backend/src/pymethod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,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))
};
Expand Down Expand Up @@ -556,18 +556,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)
}
};

Expand Down Expand Up @@ -603,7 +603,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))
};
Expand Down Expand Up @@ -650,7 +650,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)
}
}
};
Expand Down Expand Up @@ -682,7 +682,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
Expand Down Expand Up @@ -1083,7 +1083,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))
Expand Down Expand Up @@ -1191,7 +1191,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))
Expand Down

0 comments on commit 0f796e7

Please sign in to comment.