@@ -526,6 +526,23 @@ pycall_pytypeptr_get_tp_flags(VALUE obj)
526526 return Qnil ;
527527}
528528
529+ static VALUE
530+ pycall_pytypeptr_subclass_p (VALUE obj , VALUE other )
531+ {
532+ PyObject * pyobj , * pyobj_other ;
533+ int res ;
534+
535+ pyobj = get_pytypeobj_ptr (obj );
536+ pyobj_other = check_get_pytypeobj_ptr (other );
537+
538+ res = Py_API (PyObject_IsSubclass )(pyobj , pyobj_other );
539+ if (res < 0 ) {
540+ pycall_pyerror_fetch_and_raise ("PyObject_IsSubclass in pycall_pytypeptr_subclass_p" );
541+ }
542+
543+ return res ? Qtrue : Qfalse ;
544+ }
545+
529546static VALUE
530547pycall_pytypeptr_eqq (VALUE obj , VALUE other )
531548{
@@ -2108,6 +2125,7 @@ Init_pycall(void)
21082125 rb_define_method (cPyTypePtr , "__tp_name__" , pycall_pytypeptr_get_tp_name , 0 );
21092126 rb_define_method (cPyTypePtr , "__tp_basicsize__" , pycall_pytypeptr_get_tp_basicsize , 0 );
21102127 rb_define_method (cPyTypePtr , "__tp_flags__" , pycall_pytypeptr_get_tp_flags , 0 );
2128+ rb_define_method (cPyTypePtr , "subclass?" , pycall_pytypeptr_subclass_p , 1 );
21112129 rb_define_method (cPyTypePtr , "===" , pycall_pytypeptr_eqq , 1 );
21122130
21132131 /* PyCall::LibPython::API */
0 commit comments