I'm confused. I'm probably missing something, but why do you think such a check is necessary? The code I'm seeing at around line 2766 is: static Py_ssize_t match_getindex(MatchObject* self, PyObject* index) { Py_ssize_t i; if (PyInt_Check(index)) return PyInt_AsSsize_t(index); ... Is there any reason to expect that the index argument to match_getindex might be NULL? Even if it were, surely it would be the PyInt_Check call that would be affected, not PyInt_AsSsize_t? The usual pattern in Python C code is to check return values, but not incoming arguments.
abstract.c(PyNumber_AsSsize_t) shows this check of PyInt_AsSsize_t()'s parameter: 980: if (value == NULL) 981: return -1; 982: 983: /* We're done if PyInt_AsSsize_t() returns without error. */ 984: result = PyInt_AsSsize_t(value); Similar checks of this parameter occur in the following places: classobject.c(instance_length) 980 sliceobject.c(PySlice_GetIndices) 1020 sliceobject.c(PySlice_GetIndices) 123 sliceobject.c(PySlice_GetIndices) 115 ceval.c(PyEval_EvalFrameEx) 1179 _sre.c(match_getindex) 2772
> abstract.c(PyNumber_AsSsize_t) shows this check of PyInt_AsSsize_t()'s > parameter: Yup. And that's because 'value' is the return value from PyNumber_Index. PyNumber_Index might return NULL, so the check is necessary. Am closing this as invalid. I appreciate that you're trying to help here; may I suggest that you take some time to read through the various development docs available?
History
Date
User
Action
Args
2022-04-11 14:56:41
admin
set
github: 48710
2008-11-29 17:43:51
mark.dickinson
set
status: open -> closedresolution: not a bugmessages: +