diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-12-16 19:11:44 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-12-16 19:11:44 (GMT) |
commit | cb479e78e0c6f57ffc130af3a81dff648262d069 (patch) | |
tree | 54210d64fd7a8bbd1ce9b17868b58e84faf7f2d1 /Python | |
parent | 0c0b5305ae8712b8594bd512ce5a9699caf7d2b2 (diff) | |
download | cpython-cb479e78e0c6f57ffc130af3a81dff648262d069.zip cpython-cb479e78e0c6f57ffc130af3a81dff648262d069.tar.gz cpython-cb479e78e0c6f57ffc130af3a81dff648262d069.tar.bz2 |
_PyEval_SliceIndex(): Repaired the comments, and added XXX comments
about its dubious treatment of NULL (also opened a bug report on that,
but don't want to risk changing it this late in the 2.2 game).
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 3e41b9a..f99e44a 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -3328,14 +3328,18 @@ loop_subscript(PyObject *v, PyObject *w) return NULL; } -/* Extract a slice index from a PyInt or PyLong, the index is bound to - the range [-INT_MAX+1, INTMAX]. Returns 0 and an exception if there is - and error. Returns 1 on success.*/ - +/* Extract a slice index from a PyInt or PyLong, and store in *pi. + 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? +*/ int _PyEval_SliceIndex(PyObject *v, int *pi) { - if (v != NULL) { + if (v != NULL) { /* XXX why isn't this assert(v != NULL()? */ long x; if (PyInt_Check(v)) { x = PyInt_AsLong(v); @@ -3362,7 +3366,8 @@ _PyEval_SliceIndex(PyObject *v, int *pi) /* Create a long integer with a value of 0 */ long_zero = PyLong_FromLong(0L); - if (long_zero == NULL) return 0; + if (long_zero == NULL) + return 0; /* Check sign */ cmp = PyObject_RichCompareBool(v, long_zero, |