Kaydet (Commit) 8ea9f4d1 authored tarafından Guido van Rossum's avatar Guido van Rossum

Fix a stupid little bug: len() of an unsized returns -1 and leaves an

exception waiting to happen next...
üst 16926bd7
...@@ -1098,10 +1098,14 @@ builtin_len(self, args) ...@@ -1098,10 +1098,14 @@ builtin_len(self, args)
PyObject *args; PyObject *args;
{ {
PyObject *v; PyObject *v;
long res;
if (!PyArg_ParseTuple(args, "O:len", &v)) if (!PyArg_ParseTuple(args, "O:len", &v))
return NULL; 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[] = static char len_doc[] =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment