Skip to content

Commit

Permalink
Attempt to mark various generated code with #[automatically_derived]
Browse files Browse the repository at this point in the history
fixes PyO3#3989
  • Loading branch information
alex committed Mar 26, 2024
1 parent 1be2fad commit 672e23a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pyo3-macros-backend/src/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ impl<'a> FnSpec<'a> {
let init_holders = holders.init_holders(ctx);

quote! {
#[automatically_derived]
unsafe fn #ident<'py>(
py: #pyo3_path::Python<'py>,
_slf: *mut #pyo3_path::ffi::PyObject,
Expand All @@ -642,6 +643,7 @@ impl<'a> FnSpec<'a> {
let check_gil_refs = holders.check_gil_refs();

quote! {
#[automatically_derived]
unsafe fn #ident<'py>(
py: #pyo3_path::Python<'py>,
_slf: *mut #pyo3_path::ffi::PyObject,
Expand All @@ -667,6 +669,7 @@ impl<'a> FnSpec<'a> {
let check_gil_refs = holders.check_gil_refs();

quote! {
#[automatically_derived]
unsafe fn #ident<'py>(
py: #pyo3_path::Python<'py>,
_slf: *mut #pyo3_path::ffi::PyObject,
Expand All @@ -693,6 +696,7 @@ impl<'a> FnSpec<'a> {
let init_holders = holders.init_holders(ctx);
let check_gil_refs = holders.check_gil_refs();
quote! {
#[automatically_derived]
unsafe fn #ident(
py: #pyo3_path::Python<'_>,
_slf: *mut #pyo3_path::ffi::PyTypeObject,
Expand Down
2 changes: 2 additions & 0 deletions pyo3-macros-backend/src/pyclass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1301,10 +1301,12 @@ fn impl_pytypeinfo(

quote! {
#[allow(deprecated)]
#[automatically_derived]
unsafe impl #pyo3_path::type_object::HasPyGilRef for #cls {
type AsRefTarget = #pyo3_path::PyCell<Self>;
}

#[automatically_derived]
unsafe impl #pyo3_path::type_object::PyTypeInfo for #cls {
const NAME: &'static str = #cls_name;
const MODULE: ::std::option::Option<&'static str> = #module;
Expand Down
1 change: 1 addition & 0 deletions src/exceptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ macro_rules! import_exception {
#module=::std::option::Option::Some(stringify!($module))
);

#[automatically_derived]
impl $name {
fn type_object_raw(py: $crate::Python<'_>) -> *mut $crate::ffi::PyTypeObject {
use $crate::sync::GILOnceCell;
Expand Down

0 comments on commit 672e23a

Please sign in to comment.