@@ -5879,21 +5879,13 @@ get_base_by_token_recursive(PyObject *bases, void *token)
58795879int
58805880_PyType_GetBaseByToken_Borrow (PyTypeObject * type , void * token , PyTypeObject * * result )
58815881{
5882+ assert (token != NULL );
5883+ assert (PyType_Check (type ));
5884+
58825885 if (result != NULL ) {
58835886 * result = NULL ;
58845887 }
58855888
5886- if (token == NULL ) {
5887- PyErr_Format (PyExc_SystemError ,
5888- "PyType_GetBaseByToken called with token=NULL" );
5889- return -1 ;
5890- }
5891- if (!PyType_Check (type )) {
5892- PyErr_Format (PyExc_TypeError ,
5893- "expected a type, got a '%T' object" , type );
5894- return -1 ;
5895- }
5896-
58975889 if (!_PyType_HasFeature (type , Py_TPFLAGS_HEAPTYPE )) {
58985890 // No static type has a heaptype superclass,
58995891 // which is ensured by type_ready_mro().
@@ -5939,6 +5931,17 @@ _PyType_GetBaseByToken_Borrow(PyTypeObject *type, void *token, PyTypeObject **re
59395931int
59405932PyType_GetBaseByToken (PyTypeObject * type , void * token , PyTypeObject * * result )
59415933{
5934+ if (token == NULL ) {
5935+ PyErr_Format (PyExc_SystemError ,
5936+ "PyType_GetBaseByToken called with token=NULL" );
5937+ return -1 ;
5938+ }
5939+ if (!PyType_Check (type )) {
5940+ PyErr_Format (PyExc_TypeError ,
5941+ "expected a type, got a '%T' object" , type );
5942+ return -1 ;
5943+ }
5944+
59425945 int res = _PyType_GetBaseByToken_Borrow (type , token , result );
59435946 if (res > 0 && result ) {
59445947 Py_INCREF (* result );
0 commit comments