File tree Expand file tree Collapse file tree 1 file changed +8
-12
lines changed
Expand file tree Collapse file tree 1 file changed +8
-12
lines changed Original file line number Diff line number Diff line change @@ -2965,6 +2965,7 @@ static PyType_Slot array_slots[] = {
29652965 {Py_tp_alloc , PyType_GenericAlloc },
29662966 {Py_tp_new , array_new },
29672967 {Py_tp_traverse , array_tp_traverse },
2968+ {Py_tp_token , Py_TP_USE_SPEC },
29682969
29692970 /* as sequence */
29702971 {Py_sq_length , array_length },
@@ -3207,20 +3208,15 @@ static inline int
32073208array_subscr_guard (PyObject * lhs , PyObject * rhs )
32083209{
32093210 PyObject * exc = PyErr_GetRaisedException ();
3210- PyObject * module = PyType_GetModuleByDef (Py_TYPE (lhs ), & arraymodule );
3211- if (module == NULL ) {
3212- if (!PyErr_Occurred () || PyErr_ExceptionMatches (PyExc_TypeError )) {
3213- /* lhs is not an array instance - ignore the TypeError (if any) */
3214- PyErr_SetRaisedException (exc );
3215- return 0 ;
3216- }
3217- else {
3218- _PyErr_ChainExceptions1 (exc );
3219- return -1 ;
3211+ int ret = PyType_GetBaseByToken (Py_TYPE (lhs ), & array_spec , NULL );
3212+ if (ret < 0 ) {
3213+ if (PyErr_ExceptionMatches (PyExc_TypeError )) {
3214+ PyErr_Clear ();
3215+ ret = 0 ;
32203216 }
32213217 }
3222- PyErr_SetRaisedException (exc );
3223- return array_Check ( lhs , get_array_state ( module )) ;
3218+ _PyErr_ChainExceptions1 (exc );
3219+ return ret ;
32243220}
32253221
32263222static PyObject *
You can’t perform that action at this time.
0 commit comments