@@ -4,10 +4,8 @@ use crate::conversion::{FromPyObject, IntoPyObject};
44use crate :: err:: { PyErr , PyResult } ;
55use crate :: exceptions:: { PyAttributeError , PyTypeError } ;
66use crate :: ffi_ptr_ext:: FfiPtrExt ;
7- #[ cfg( not( _Py_OPAQUE_PYOBJECT ) ) ]
7+ #[ cfg( not( all ( Py_3_12 , Py_LIMITED_API ) ) ) ]
88use crate :: impl_:: pycell:: { PyClassObjectBase , PyStaticClassObject } ;
9- #[ cfg( _Py_OPAQUE_PYOBJECT) ]
10- use crate :: impl_:: pycell:: { PyVariableClassObject , PyVariableClassObjectBase } ;
119use crate :: instance:: Bound ;
1210use crate :: internal:: get_slot:: TP_DESCR_GET ;
1311use crate :: py_result_ext:: PyResultExt ;
@@ -54,21 +52,19 @@ pyobject_native_type_info!(
5452) ;
5553
5654pyobject_native_type_sized ! ( PyAny , ffi:: PyObject ) ;
57- // We cannot use `pyobject_subclassable_native_type!()` because it cfgs out on `Py_LIMITED_API`.
55+ // We cannot use `pyobject_subclassable_native_type!()` because it cfgs out on `Py_LIMITED_API` for Python < 3.12.
56+ #[ cfg( not( all( Py_3_12 , Py_LIMITED_API ) ) ) ]
5857impl crate :: impl_:: pyclass:: PyClassBaseType for PyAny {
59- #[ cfg( _Py_OPAQUE_PYOBJECT) ]
60- type LayoutAsBase = PyVariableClassObjectBase ;
61- #[ cfg( not( _Py_OPAQUE_PYOBJECT) ) ]
6258 type LayoutAsBase = PyClassObjectBase < ffi:: PyObject > ;
6359 type BaseNativeType = PyAny ;
6460 type Initializer = crate :: impl_:: pyclass_init:: PyNativeTypeInitializer < Self > ;
6561 type PyClassMutability = crate :: pycell:: impl_:: ImmutableClass ;
66- #[ cfg( _Py_OPAQUE_PYOBJECT) ]
67- type Layout < T : crate :: impl_:: pyclass:: PyClassImpl > = PyVariableClassObject < T > ;
68- #[ cfg( not( _Py_OPAQUE_PYOBJECT) ) ]
6962 type Layout < T : crate :: impl_:: pyclass:: PyClassImpl > = PyStaticClassObject < T > ;
7063}
7164
65+ #[ cfg( all( Py_3_12 , Py_LIMITED_API ) ) ]
66+ pyobject_subclassable_native_type ! ( PyAny , ffi:: PyObject ) ;
67+
7268/// This trait represents the Python APIs which are usable on all Python objects.
7369///
7470/// It is recommended you import this trait via `use pyo3::prelude::*` rather than
0 commit comments