diff Python/ceval.c @ 21441:05ad7a69d933 legacy-trunk

_PyEval_SliceIndex(): explain why a NULL argument is allowed (thanks to Guido for the revelation).
author Tim Peters <tim.peters@gmail.com>
date Sun, 16 Dec 2001 19:44:20 +0000
parents 30efe46f8e3c
children aac23331a25d
line wrap: on
line diff
--- a/Python/ceval.c	Sun Dec 16 19:11:44 2001 +0000
+++ b/Python/ceval.c	Sun Dec 16 19:44:20 2001 +0000
@@ -3332,14 +3332,14 @@
    Silently reduce values larger than INT_MAX to INT_MAX, and silently
    boost values less than -INT_MAX to 0.  Return 0 on error, 1 on success.
 */
-/* XXX If v is NULL, this goes out of its way to indicate success(!), but
-   XXX doesn't store into *pi.  Why isn't that an error, or at least v!=NULL
-   XXX an asserted precondition?
+/* Note:  If v is NULL, return success without storing into *pi.  This
+   is because_PyEval_SliceIndex() is called by apply_slice(), which can be
+   called by the SLICE opcode with v and/or w equal to NULL.
 */
 int
 _PyEval_SliceIndex(PyObject *v, int *pi)
 {
-	if (v != NULL) {  /* XXX why isn't this assert(v != NULL()? */
+	if (v != NULL) {
 		long x;
 		if (PyInt_Check(v)) {
 			x = PyInt_AsLong(v);