@@ -713,40 +713,33 @@ pub unsafe fn Py_XDECREF(op: *mut PyObject) {
713713}
714714
715715extern "C" {
716- #[ cfg( all( Py_3_10 , Py_LIMITED_API ) ) ]
716+ #[ cfg( all( Py_3_10 , Py_LIMITED_API , not( PyPy ) ) ) ]
717+ #[ cfg_attr( docsrs, doc( cfg( Py_3_10 ) ) ) ]
717718 pub fn Py_NewRef ( obj : * mut PyObject ) -> * mut PyObject ;
718- #[ cfg( all( Py_3_10 , Py_LIMITED_API ) ) ]
719+ #[ cfg( all( Py_3_10 , Py_LIMITED_API , not( PyPy ) ) ) ]
720+ #[ cfg_attr( docsrs, doc( cfg( Py_3_10 ) ) ) ]
719721 pub fn Py_XNewRef ( obj : * mut PyObject ) -> * mut PyObject ;
720722}
721723
722- // Technically these macros are only available in the C header from 3.10 and up, however their
723- // implementation works on all supported Python versions so we define these macros on all
724- // versions for simplicity.
724+ // macro _Py_NewRef not public; reimplemented directly inside Py_NewRef here
725+ // macro _Py_XNewRef not public; reimplemented directly inside Py_XNewRef here
725726
727+ #[ cfg( all( Py_3_10 , any( not( Py_LIMITED_API ) , PyPy ) ) ) ]
728+ #[ cfg_attr( docsrs, doc( cfg( Py_3_10 ) ) ) ]
726729#[ inline]
727- pub unsafe fn _Py_NewRef ( obj : * mut PyObject ) -> * mut PyObject {
730+ pub unsafe fn Py_NewRef ( obj : * mut PyObject ) -> * mut PyObject {
728731 Py_INCREF ( obj) ;
729732 obj
730733}
731734
735+ #[ cfg( all( Py_3_10 , any( not( Py_LIMITED_API ) , PyPy ) ) ) ]
736+ #[ cfg_attr( docsrs, doc( cfg( Py_3_10 ) ) ) ]
732737#[ inline]
733- pub unsafe fn _Py_XNewRef ( obj : * mut PyObject ) -> * mut PyObject {
738+ pub unsafe fn Py_XNewRef ( obj : * mut PyObject ) -> * mut PyObject {
734739 Py_XINCREF ( obj) ;
735740 obj
736741}
737742
738- #[ cfg( all( Py_3_10 , not( Py_LIMITED_API ) ) ) ]
739- #[ inline]
740- pub unsafe fn Py_NewRef ( obj : * mut PyObject ) -> * mut PyObject {
741- _Py_NewRef ( obj)
742- }
743-
744- #[ cfg( all( Py_3_10 , not( Py_LIMITED_API ) ) ) ]
745- #[ inline]
746- pub unsafe fn Py_XNewRef ( obj : * mut PyObject ) -> * mut PyObject {
747- _Py_XNewRef ( obj)
748- }
749-
750743#[ cfg_attr( windows, link( name = "pythonXY" ) ) ]
751744extern "C" {
752745 #[ cfg( not( GraalPy ) ) ]
0 commit comments