mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
_PyEval_SliceIndex(): explain why a NULL argument is allowed (thanks
to Guido for the revelation).
This commit is contained in:
parent
cb479e78e0
commit
b519638d1e
1 changed files with 4 additions and 4 deletions
|
@ -3332,14 +3332,14 @@ loop_subscript(PyObject *v, PyObject *w)
|
||||||
Silently reduce values larger than INT_MAX to INT_MAX, and silently
|
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.
|
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
|
/* Note: If v is NULL, return success without storing into *pi. This
|
||||||
XXX doesn't store into *pi. Why isn't that an error, or at least v!=NULL
|
is because_PyEval_SliceIndex() is called by apply_slice(), which can be
|
||||||
XXX an asserted precondition?
|
called by the SLICE opcode with v and/or w equal to NULL.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
_PyEval_SliceIndex(PyObject *v, int *pi)
|
_PyEval_SliceIndex(PyObject *v, int *pi)
|
||||||
{
|
{
|
||||||
if (v != NULL) { /* XXX why isn't this assert(v != NULL()? */
|
if (v != NULL) {
|
||||||
long x;
|
long x;
|
||||||
if (PyInt_Check(v)) {
|
if (PyInt_Check(v)) {
|
||||||
x = PyInt_AsLong(v);
|
x = PyInt_AsLong(v);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue