Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use PyType_GetBaseByToken
  • Loading branch information
iritkatriel committed May 4, 2025
commit 70ebe719fdf09ddad96560c769e7005d76ece049
20 changes: 8 additions & 12 deletions Modules/arraymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2965,6 +2965,7 @@ static PyType_Slot array_slots[] = {
{Py_tp_alloc, PyType_GenericAlloc},
{Py_tp_new, array_new},
{Py_tp_traverse, array_tp_traverse},
{Py_tp_token, Py_TP_USE_SPEC},

/* as sequence */
{Py_sq_length, array_length},
Expand Down Expand Up @@ -3207,20 +3208,15 @@ static inline int
array_subscr_guard(PyObject *lhs, PyObject *rhs)
{
PyObject *exc = PyErr_GetRaisedException();
PyObject *module = PyType_GetModuleByDef(Py_TYPE(lhs), &arraymodule);
if (module == NULL) {
if (!PyErr_Occurred() || PyErr_ExceptionMatches(PyExc_TypeError)) {
/* lhs is not an array instance - ignore the TypeError (if any) */
PyErr_SetRaisedException(exc);
return 0;
}
else {
_PyErr_ChainExceptions1(exc);
return -1;
int ret = PyType_GetBaseByToken(Py_TYPE(lhs), &array_spec, NULL);
if (ret < 0) {
if (PyErr_ExceptionMatches(PyExc_TypeError)) {
PyErr_Clear();
ret = 0;
}
}
PyErr_SetRaisedException(exc);
return array_Check(lhs, get_array_state(module));
_PyErr_ChainExceptions1(exc);
return ret;
}

static PyObject *
Expand Down