@@ -3,6 +3,8 @@ use crate::pyport::{Py_hash_t, Py_ssize_t};
33use crate :: refcount;
44#[ cfg( Py_GIL_DISABLED ) ]
55use crate :: PyMutex ;
6+ #[ cfg( all( not( GraalPy ) , not( all( Py_3_13 , Py_LIMITED_API ) ) ) ) ]
7+ use crate :: Py_NewRef ;
68use std:: ffi:: { c_char, c_int, c_uint, c_ulong, c_void} ;
79use std:: mem;
810#[ cfg( Py_GIL_DISABLED ) ]
@@ -233,6 +235,8 @@ pub unsafe fn Py_SIZE(ob: *mut PyObject) -> Py_ssize_t {
233235#[ cfg( all( Py_LIMITED_API , Py_3_15 ) ) ]
234236extern_libpython ! {
235237 pub fn Py_IS_TYPE ( ob: * mut PyObject , tp: * mut PyTypeObject ) -> c_int;
238+ pub fn Py_SET_SIZE ( ob: * mut PyVarObject , size: Py_ssize_t ) ;
239+ pub fn Py_SET_TYPE ( ob: * mut PyObject , type : * mut PyTypeObject ) ;
236240}
237241
238242#[ inline]
@@ -241,9 +245,11 @@ pub unsafe fn Py_IS_TYPE(ob: *mut PyObject, tp: *mut PyTypeObject) -> c_int {
241245 ( Py_TYPE ( ob) == tp) as c_int
242246}
243247
244- // skipped Py_SET_TYPE
245-
246- // skipped Py_SET_SIZE
248+ #[ inline]
249+ #[ cfg( not( all( Py_LIMITED_API , Py_3_15 ) ) ) ]
250+ pub unsafe fn Py_SET_SIZE ( ob : * mut PyVarObject , size : Py_ssize_t {
251+ ( * ob) . ob_size = size
252+ }
247253
248254pub type unaryfunc = unsafe extern "C" fn ( * mut PyObject ) -> * mut PyObject ;
249255pub type binaryfunc = unsafe extern "C" fn ( * mut PyObject , * mut PyObject ) -> * mut PyObject ;
@@ -643,7 +649,14 @@ pub unsafe fn Py_IsNone(x: *mut PyObject) -> c_int {
643649 Py_Is ( x, Py_None ( ) )
644650}
645651
646- // skipped Py_RETURN_NONE
652+ #[ inline]
653+ pub unsafe fn Py_RETURN_NONE ( ) -> * mut PyObject {
654+ #[ cfg( all( not( GraalPy ) , not( all( Py_3_13 , Py_LIMITED_API ) ) ) ) ]
655+ Py_NewRef ( Py_None ( ) )
656+
657+ #[ cfg( all( not( GraalPy ) , all( Py_3_13 , Py_LIMITED_API ) ) ) ]
658+ Py_None ( )
659+ }
647660
648661extern_libpython ! {
649662 #[ cfg( all( not( GraalPy ) , not( all( Py_3_13 , Py_LIMITED_API ) ) ) ) ]
@@ -666,7 +679,14 @@ pub unsafe fn Py_NotImplemented() -> *mut PyObject {
666679 return _Py_NotImplementedStructReference;
667680}
668681
669- // skipped Py_RETURN_NOTIMPLEMENTED
682+ #[ inline]
683+ pub unsafe fn Py_RETURN_NOTIMPLEMENTED ( ) -> * mut PyObject {
684+ #[ cfg( all( not( GraalPy ) , not( all( Py_3_13 , Py_LIMITED_API ) ) ) ) ]
685+ Py_NewRef ( Py_NotImplemented ( ) )
686+
687+ #[ cfg( all( not( GraalPy ) , all( Py_3_13 , Py_LIMITED_API ) ) ) ]
688+ Py_NotImplemented ( )
689+ }
670690
671691/* Rich comparison opcodes */
672692pub const Py_LT : c_int = 0 ;
0 commit comments