Fix a stupid little bug: len() of an unsized returns -1 and leaves an
exception waiting to happen next...
This commit is contained in:
parent
16926bd75e
commit
8ea9f4d10a
|
@ -1098,10 +1098,14 @@ builtin_len(self, args)
|
|||
PyObject *args;
|
||||
{
|
||||
PyObject *v;
|
||||
long res;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O:len", &v))
|
||||
return NULL;
|
||||
return PyInt_FromLong((long)PyObject_Length(v));
|
||||
res = PyObject_Length(v);
|
||||
if (res < 0 && PyErr_Occurred())
|
||||
return NULL;
|
||||
return PyInt_FromLong(res);
|
||||
}
|
||||
|
||||
static char len_doc[] =
|
||||
|
|
Loading…
Reference in New Issue