Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b519638

Browse files
committed
_PyEval_SliceIndex(): explain why a NULL argument is allowed (thanks
to Guido for the revelation).
1 parent cb479e7 commit b519638

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Python/ceval.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3332,14 +3332,14 @@ loop_subscript(PyObject *v, PyObject *w)
33323332
Silently reduce values larger than INT_MAX to INT_MAX, and silently
33333333
boost values less than -INT_MAX to 0. Return 0 on error, 1 on success.
33343334
*/
3335-
/* XXX If v is NULL, this goes out of its way to indicate success(!), but
3336-
XXX doesn't store into *pi. Why isn't that an error, or at least v!=NULL
3337-
XXX an asserted precondition?
3335+
/* Note: If v is NULL, return success without storing into *pi. This
3336+
is because_PyEval_SliceIndex() is called by apply_slice(), which can be
3337+
called by the SLICE opcode with v and/or w equal to NULL.
33383338
*/
33393339
int
33403340
_PyEval_SliceIndex(PyObject *v, int *pi)
33413341
{
3342-
if (v != NULL) { /* XXX why isn't this assert(v != NULL()? */
3342+
if (v != NULL) {
33433343
long x;
33443344
if (PyInt_Check(v)) {
33453345
x = PyInt_AsLong(v);

0 commit comments

Comments
 (0)