Skip to content

Commit 672e23a

Browse files
committed
Attempt to mark various generated code with #[automatically_derived]
fixes PyO3#3989
1 parent 1be2fad commit 672e23a

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

pyo3-macros-backend/src/method.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ impl<'a> FnSpec<'a> {
621621
let init_holders = holders.init_holders(ctx);
622622

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

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

669671
quote! {
672+
#[automatically_derived]
670673
unsafe fn #ident<'py>(
671674
py: #pyo3_path::Python<'py>,
672675
_slf: *mut #pyo3_path::ffi::PyObject,
@@ -693,6 +696,7 @@ impl<'a> FnSpec<'a> {
693696
let init_holders = holders.init_holders(ctx);
694697
let check_gil_refs = holders.check_gil_refs();
695698
quote! {
699+
#[automatically_derived]
696700
unsafe fn #ident(
697701
py: #pyo3_path::Python<'_>,
698702
_slf: *mut #pyo3_path::ffi::PyTypeObject,

pyo3-macros-backend/src/pyclass.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,10 +1301,12 @@ fn impl_pytypeinfo(
13011301

13021302
quote! {
13031303
#[allow(deprecated)]
1304+
#[automatically_derived]
13041305
unsafe impl #pyo3_path::type_object::HasPyGilRef for #cls {
13051306
type AsRefTarget = #pyo3_path::PyCell<Self>;
13061307
}
13071308

1309+
#[automatically_derived]
13081310
unsafe impl #pyo3_path::type_object::PyTypeInfo for #cls {
13091311
const NAME: &'static str = #cls_name;
13101312
const MODULE: ::std::option::Option<&'static str> = #module;

src/exceptions.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ macro_rules! import_exception {
103103
#module=::std::option::Option::Some(stringify!($module))
104104
);
105105

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

0 commit comments

Comments
 (0)